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 <unistd.h>
00007 #include <sys/types.h>
00008 #include <sys/stat.h>
00009 #include <fcntl.h>
00010 
00011 #include <opencv/cv.h>
00012 #include <opencv/highgui.h>
00013 
00014 #include "opt_nm33_uvc.h"
00015 
00016 int main (int argc, char* argv[]) {
00017   char dev[256];
00018   int fd;
00019   if ( getuid() != 0 ) {
00020     fprintf(stderr, "\033[31m### you must run this program as a root : sudo %s\033[0m\n", argv[0]);
00021     exit(1);
00022   }
00023   for (int i = 0; i < 16; i++ ) {
00024     sprintf(dev, "/dev/video%d", i);
00025     if ( ( fd = open((const char *)dev,O_RDWR))  > 0 ) {
00026       fprintf(stderr, ";; video capabilities %s(%d)\n", dev, fd);
00027 
00028       struct v4l2_capability vd;
00029       memset(&vd, 0, sizeof(struct v4l2_capability));
00030       if(ioctl(fd, VIDIOC_QUERYCAP, &vd) < 0) {
00031         perror("ioctl(VIDIOC_QUERYCAP)");
00032         return false;
00033       }
00034       fprintf(stderr, ";; vd.driver         = %s\n", vd.driver);
00035       fprintf(stderr, ";; vd.card           = %s\n", vd.card);
00036       fprintf(stderr, ";; vd.buf_info       = %s\n", vd.bus_info);
00037       fprintf(stderr, ";; vd.version        = %d\n", vd.version);
00038 
00039       if (strcmp("NM30 Ultra Wideview Camera", (const char*)vd.card) == 0 ) {
00040         set_XU_control(fd);
00041       }
00042     }
00043   }
00044 }
00045 


opt_camera
Author(s): Kei Okada
autogenerated on Sun Jan 25 2015 12:37:47