00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __CAPTURE_H__
00022 #define __CAPTURE_H__
00023
00024 #include <sys/mman.h>
00025 #include <sys/ioctl.h>
00026 #include <sys/time.h>
00027 #include <fcntl.h>
00028
00029 #include <stdlib.h>
00030 #include <unistd.h>
00031 #include <stdio.h>
00032 #include <errno.h>
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <linux/fs.h>
00042 #include <linux/kernel.h>
00043
00044
00045
00046
00047
00048
00049 #include "videodev2.h"
00050
00051 #define DEFAULT_VIDEO_DEVICE "/dev/video"
00052 #define VIDEO_STANDARD "NTSC"
00053
00054 #ifdef USE_METEOR
00055 #define DEFAULT_VIDEO_FORMAT V4L2_PIX_FMT_UYVY
00056 #else
00057 #define DEFAULT_VIDEO_FORMAT V4L2_PIX_FMT_YUYV
00058 #endif
00059
00060 #define DEFAULT_IMAGE_WIDTH 320
00061 #define DEFAULT_IMAGE_HEIGHT 240
00062
00063
00064 #define STREAMBUFS 10
00065
00066 class capture {
00067 struct vimage_t {
00068 v4l2_buffer vidbuf;
00069 char *data;
00070 };
00071
00072 int vid_fd;
00073 vimage_t vimage[STREAMBUFS];
00074 struct v4l2_format fmt;
00075
00076 unsigned char *current;
00077
00078 int width,height;
00079 struct v4l2_buffer tempbuf;
00080 bool captured_frame;
00081 public:
00082 capture() {vid_fd = 0; current=NULL; captured_frame = false;}
00083 ~capture() {close();}
00084
00085 bool initialize(const char *device,int nwidth,int nheight,int nfmt, bool continuous);
00086 bool initialize(int nwidth,int nheight)
00087 {return(initialize(NULL,nwidth,nheight,0,false));}
00088 bool initialize()
00089 {return(initialize(NULL,0,0,0,false));}
00090
00091 void close();
00092
00093 int getFD(){return vid_fd;}
00094 unsigned char *captureFrame(int &index,int &field);
00095 unsigned char *captureFrame();
00096 void releaseFrame(unsigned char* frame, int index);
00097
00098 unsigned char *getFrame() {return(current);}
00099
00100 bool set_contrast(int contrast);
00101 bool set_brightness(int brightness);
00102 bool set_hue(int hue);
00103 bool set_saturation(int color);
00104 bool set_auto_white_balance(bool white_balance);
00105
00106
00107
00108 int getWidth() {return(width);}
00109 int getHeight() {return(height);}
00110 };
00111
00112 #endif // __CAPTURE_H__