init_xu_register.cpp
Go to the documentation of this file.
00001 /*                                                            */
00002 /* This code is based on luvcview_wr_100823 from Opt corp.    */
00003 /*                                                            */
00004 /*                  2010/09/15    k-okada@jsk.t.u-tokyo.ac.jp */
00005 
00006 #include <sys/types.h>
00007 #include <sys/stat.h>
00008 #include <fcntl.h>
00009 
00010 #include <opencv/cv.h>
00011 #include <opencv/highgui.h>
00012 
00013 #include "opt_nm33_uvc.h"
00014 
00015 int main (int argc, char* argv[]) {
00016   char dev[256];
00017   int fd;
00018   if ( getuid() != 0 ) {
00019     fprintf(stderr, "\033[31m### you must run this program as a root : sudo %s\033[0m\n", argv[0]);
00020     exit(1);
00021   }
00022   for (int i = 0; i < 16; i++ ) {
00023     sprintf(dev, "/dev/video%d", i);
00024     if ( ( fd = open((const char *)dev,O_RDWR))  > 0 ) {
00025       fprintf(stderr, ";; video capabilities %s(%d)\n", dev, fd);
00026 
00027       struct v4l2_capability vd;
00028       memset(&vd, 0, sizeof(struct v4l2_capability));
00029       if(ioctl(fd, VIDIOC_QUERYCAP, &vd) < 0) {
00030         perror("ioctl(VIDIOC_QUERYCAP)");
00031         return false;
00032       }
00033       fprintf(stderr, ";; vd.driver         = %s\n", vd.driver);
00034       fprintf(stderr, ";; vd.card           = %s\n", vd.card);
00035       fprintf(stderr, ";; vd.buf_info       = %s\n", vd.bus_info);
00036       fprintf(stderr, ";; vd.version        = %d\n", vd.version);
00037 
00038       if (strcmp("NM30 Ultra Wideview Camera", (const char*)vd.card) == 0 ) {
00039         set_XU_control(fd);
00040       }
00041     }
00042   }
00043 }
00044 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


opt_camera
Author(s): Kei Okada
autogenerated on Sat Mar 23 2013 21:00:13