int main(int argc, char **argv){ int do_list_formats = 0; dev_name = "/dev/video0"; int input = 100; int command = V4L2_CID_GAMMA; int doCommand = 0; imageName = "img.png"; while(1){ int index; int c; c = getopt_long(argc, argv, short_options, long_options, &index); if(-1 == c){ break; } switch(c){ case 0: /* getopt_long() flag */ break; case 'd': dev_name = optarg; break; case 'h': usage(stdout, argc, argv); exit(EXIT_SUCCESS); case 'l': do_list_formats = 1; break; case 'a': command = V4L2_CID_EXPOSURE_AUTO; input = atoi(optarg); doCommand = 1; break; case 'e': command = V4L2_CID_EXPOSURE_ABSOLUTE; input = atoi(optarg); doCommand = 1; break; case 'i': command = V4L2_CID_GAIN; input = atoi(optarg); doCommand = 1; break; case 'g': command = V4L2_CID_GAMMA; input = atoi(optarg); doCommand = 1; break; case 'o': imageName = optarg; break; case 't': imageName = NULL; break; default: usage(stderr, argc, argv); exit(EXIT_FAILURE); } } open_device(); if(doCommand){ int temp = 0; getControl(&temp, command); printf("Executing command 0x%X, previous value: %d ", command, temp); setControl(input, command); getControl(&temp, command); printf("current value: %d\n", temp); close_device(); exit(EXIT_SUCCESS); } if(do_list_formats){ list_format_info(); close_device(); exit(EXIT_SUCCESS); } init_device(); start_capturing(); mainloop(); stop_capturing(); uninit_device(); printf("\n"); close_device(); exit(EXIT_SUCCESS); return 0; }
int main (int argc, char ** argv) { int do_list_formats = 0; int do_capture = 1; dev_name = "/dev/video"; for (;;) { int index; int c; c = getopt_long (argc, argv, short_options, long_options, &index); if (-1 == c) break; switch (c) { case 0: /* getopt_long() flag */ break; case 'd': dev_name = optarg; break; case 'h': usage (stdout, argc, argv); exit (EXIT_SUCCESS); case 'm': io = IO_METHOD_MMAP; break; case 'r': io = IO_METHOD_READ; break; case 'u': io = IO_METHOD_USERPTR; break; case 'l': do_list_formats = 1; do_capture = 0; break; default: usage (stderr, argc, argv); exit (EXIT_FAILURE); } } //set_framerate (); open_device (); if (do_list_formats) { list_format_info (); } if (do_capture) { init_device (); start_capturing (); mainloop (); stop_capturing (); uninit_device (); } printf ("\n"); close_device (); exit (EXIT_SUCCESS); return 0; }