1313#include < string.h>
1414#include < errno.h>
1515#include < stdlib.h>
16- #include < linux/videodev2.h>
17- #include < sys/ioctl.h>
1816#include < signal.h>
1917
20- #include < fstream>
21-
2218#include " logger.h"
2319
2420#include " V4l2Device.h"
@@ -43,22 +39,28 @@ int main(int argc, char* argv[])
4339{
4440int verbose=0 ;
4541const char *in_devname =" /dev/video0" ;
46- int c =0 ;
4742V4l2IoType ioTypeIn = IOTYPE_MMAP;
43+ int format =0 ;
44+ int width =0 ;
45+ int height =0 ;
46+ int fps =0 ;
4847
49- while ((c =getopt (argc, argv," hP:F:v::rw" )) != -1 )
48+ int c =0 ;
49+ while ((c =getopt (argc, argv," hv:" " G:f:r" )) != -1 )
5050{
5151switch (c)
5252{
53- case ' v' :verbose =1 ;if (optarg && *optarg==' v' ) verbose++;break ;
54- case ' r' :ioTypeIn = IOTYPE_READWRITE;break ;
53+ case ' v' :verbose =1 ;if (optarg && *optarg==' v' ) verbose++;break ;
54+ case ' r' :ioTypeIn = IOTYPE_READWRITE ;break ;
55+ case ' G' :sscanf (optarg," %dx%dx%d" , &width, &height, &fps) ;break ;
56+ case ' f' :format =V4l2Device::fourcc (optarg) ;break ;
5557case ' h' :
5658{
57- std::cout << argv[0 ] <<" [-v[v]] [-W width] [-H height] source_device dest_device " << std::endl;
59+ std::cout << argv[0 ] <<" [-v[v]] [-G < width>x<height>x<fps> ] [-f format] [device] [-r] " << std::endl;
5860std::cout <<" \t -v : verbose" << std::endl;
5961std::cout <<" \t -vv : very verbose" << std::endl;
6062std::cout <<" \t -r : V4L2 capture using read interface (default use memory mapped buffers)" << std::endl;
61- std::cout <<" \t source_device : V4L2 capture device (default" << in_devname <<" )" << std::endl;
63+ std::cout <<" \t device : V4L2 capture device (default" << in_devname <<" )" << std::endl;
6264exit (0 );
6365}
6466}
@@ -73,7 +75,7 @@ int main(int argc, char* argv[])
7375initLogger (verbose);
7476
7577// init V4L2 capture interface
76- V4L2DeviceParametersparam (in_devname,0 , 0 , 0 , 0 , ioTypeIn, verbose);
78+ V4L2DeviceParametersparam (in_devname,format, width, height, fps , ioTypeIn, verbose);
7779V4l2Capture* videoCapture =V4l2Capture::create (param);
7880
7981if (videoCapture ==NULL )
@@ -84,7 +86,7 @@ int main(int argc, char* argv[])
8486{
8587timeval tv;
8688
87- LOG (NOTICE) <<" Start reading from" << in_devname ;
89+ LOG (NOTICE) <<" Start reading from" << in_devname;
8890signal (SIGINT,sighandler);
8991while (!stop)
9092{
@@ -102,7 +104,7 @@ int main(int argc, char* argv[])
102104}
103105else
104106{
105- LOG (DEBUG ) <<" size:" << rsize;
107+ LOG (NOTICE ) <<" size:" << rsize;
106108}
107109}
108110else if (ret == -1 )