UvcInterface.h

00001 #include <linux/types.h>
00002 #include <linux/videodev2.h>
00003 #include <string.h>
00004 
00005 class UvcInterface;
00006 
00007 #ifndef UVCINTERFACE_H_
00008 #define UVCINTERFACE_H_
00009 
00010 class UvcInterface
00011 {
00012         public:
00013                 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;}
00014                 ~UvcInterface(void) {device=0;Close();}
00015                 
00016                 int Open(void);
00017                 int Close(void);
00018                 int Read(void);
00019                 
00020                 int GetWidth(void) const;
00021                 int GetHeight(void) const;
00022                 
00023                 int GetFrameSize(void) const {return frameSize;}
00024                 void CopyFrame(unsigned char *dest) const {memcpy(dest,frame,frameSize);}
00025 
00026                 bool IsOpen(void) const {return fd!=-1;}
00027                 
00028         private:
00029                 char const *device;
00030 
00031                 unsigned char *frame;
00032                 int frameSize;
00033                 
00034                 unsigned char *buffer[2];
00035                 int length[2];
00036                 
00037                 int fd;
00038                 
00039                 v4l2_capability cap;
00040                 v4l2_format fmt;
00041                 
00042                 static const int dht_size;
00043                 static const unsigned char dht_data[];
00044                 
00045                 int width;
00046                 int height;
00047 };
00048 
00049 #endif /*UVCINTERFACE_H_*/

Last updated 12 September 2005 21:38:45