UvcInterface.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <linux/types.h>
00024 #include <linux/videodev2.h>
00025 #include <string.h>
00026
00027 class UvcInterface;
00028
00029 #ifndef UVCINTERFACE_H_
00030 #define UVCINTERFACE_H_
00031
00032 class UvcInterface
00033 {
00034 public:
00035 UvcInterface(char const *sDevice,int aWidth=320,int aHeight=240):device(sDevice),frame(0),frameSize(0),fd(-1),width(aWidth),height(aHeight){buffer[0]=0;buffer[1]=0;}
00036 ~UvcInterface(void) {device=0;Close();}
00037
00038 int Open(void);
00039 int Close(void);
00040 int Read(void);
00041
00042 int GetWidth(void) const;
00043 int GetHeight(void) const;
00044
00045 int GetFrameSize(void) const {return frameSize;}
00046 void CopyFrame(unsigned char *dest) const {memcpy(dest,frame,frameSize);}
00047
00048 bool IsOpen(void) const {return fd!=-1;}
00049
00050 private:
00051 char const *device;
00052
00053 unsigned char *frame;
00054 int frameSize;
00055
00056 unsigned char *buffer[2];
00057 int length[2];
00058
00059 int fd;
00060
00061 v4l2_capability cap;
00062 v4l2_format fmt;
00063
00064 static const int dht_size;
00065 static const unsigned char dht_data[];
00066
00067 int width;
00068 int height;
00069 };
00070
00071 #endif