📄 video.h
字号:
/**-****************************************************************************************** *class : video *description: this class is on the board DOOR,it reads the net eye scanner,and write it on the * can bus.And this cache hold only one line of the whole graph.but it tranports * the data to the KERNEL MODULE in which the data is stored the whole graph for * each cache *version: 0.01 *author: YslayerY *begain_date: 2008-7-21 *finish_date: ?? *modify_times: *******************************************************************************************/#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <linux/videodev.h>#include <sys/ioctl.h>#include <libgen.h>#include<pthread.h>#include <fcntl.h>#include <sys/mman.h>#include<getopt.h>#include<qtimer.h>#include"configure.h"#include"font.h"// video-jpeg#include<jpeglib.h>#include<sys/mman.h>#include<sys/types.h>#define CAN_DEV "/dev/can/0"///definations#define ERR_FRAME_BUFFER 1#define ERR_VIDEO_OPEN 2#define ERR_VIDEO_GCAP 3#define ERR_VIDEO_GPIC 4#define ERR_VIDEO_SPIC 5#define ERR_SYNC 6#define ERR_FRAME_USING 7#define ERR_GET_FRAME 8#define V4L_FILE "/dev/v4l/video0"#define JpegFileName "shot.jpeg"#define FRAME_SIZE 16*160*120/8/* this class use a timer to timely read v4l,and diff last image ,if differece is big enough,then it compress the image to jpeg and signal a video_transmitor class to transmit this jpeg image */struct v4l{///vedio for linux int fd; struct video_capability capability; struct video_buffer buffer; struct video_window window; struct video_channel channel[8]; struct video_picture picture; struct video_tuner tuner; struct video_audio audio[8]; struct video_mmap mmap; struct video_mbuf mbuf; unsigned char *map; int frame_current;//what 's the frame number being captured currently? int frame_using[2];};class video : public QObject{ Q_OBJECTpublic: video(); ~video();public slots://this is the video control part int shut_video(); int restart_video(int time = 1000);signals: void signal_video_need_trans(); void signal_video_detect_mov();//this is the video controling functions public://this is the can part// int write_can(short * image); int open_video(int,int,int,int); int start_video(); unsigned char * get_frame_address(); int get_grab_frame(int frame); int get_first_frame(); int get_next_frame();// this is the video-jpeg part int putImageJpeg(char * fileName,unsigned char * mem,int quality); int proc_img(RGB24 * r,unsigned char * buf,int sx,int sy); int cmp_blks(RGB24 * a,RGB24 * b,int num,int depth,int c_limit,int b_limit); public slots: void read_video_write_jpeg();private: v4l vd; int stop; QTimer timer; pthread_cond_t write_OK; RGB24 color[DEFAULT_BLK_X*DEFAULT_BLK_Y*2]; int which;// this is the jpeg compress part int color_diff_ts; /* default color diff threshold */ int hotblk_ts;};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -