Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- uvccapture-0.5/uvccapture.c 2011-04-22 18:19:57.000000000 +1000
- +++ uvccapture-0.6/uvccapture.c 2011-09-23 21:13:09.000000000 +1000
- @@ -58,6 +58,8 @@
- fprintf (stderr, "-o<filename>\tOutput filename(default: snap.jpg)\n");
- fprintf (stderr, "-d<device>\tV4L2 Device(default: /dev/video0)\n");
- fprintf (stderr,
- + "-b\t\tRun in the background\n");
- + fprintf (stderr,
- "-x<width>\tImage Width(must be supported by device)\n");
- fprintf (stderr,
- "-y<height>\tImage Height(must be supported by device)\n");
- @@ -299,6 +301,7 @@
- unsigned char* imageWithDHT = NULL;
- int imageWithDHTSize = 0;
- int preDelay = 0;
- + boolean backGround = FALSE;
- (void) signal (SIGINT, sigcatch);
- (void) signal (SIGQUIT, sigcatch);
- @@ -325,6 +328,10 @@
- snprintf(outputfile, MAXFILENAMELENGTH, "%s", &argv[1][2]);
- break;
- + case 'b':
- + backGround = TRUE;
- + break;
- +
- case 'd':
- videodevice = &argv[1][2];
- break;
- @@ -410,6 +417,10 @@
- if (post_capture_command[0])
- fprintf (stderr, "Executing '%s' after each image capture\n",
- post_capture_command[0]);
- + if (backGround)
- + fprintf (stderr, "Will switch to run in the background\n");
- + else
- + fprintf (stderr, "Will not switch to run in the background\n");
- }
- videoIn = (struct vdIn *) calloc (1, sizeof (struct vdIn));
- if (init_videoIn
- @@ -456,17 +467,43 @@
- } else if (verbose >= 1) {
- fprintf (stderr, "Camera gain level is %d\n",
- v4l2GetControl (videoIn, V4L2_CID_GAIN));
- }*/
- ref_time = time (NULL);
- - while (run) {
- - if( preDelay ) {
- - // allowing camera to adjust exposure
- - uvcGrab(videoIn);
- - videoIn->getPict = 0;
- - if (verbose >= 0)
- + if(backGround)
- + {
- + if(verbose > 0)
- + fprintf (stderr, "starting the daemonising process\n");
- +
- + verbose = 0;
- + pid_t pid = fork();
- + if(pid < 0)
- + {
- + fprintf (stderr, "Unable to daemonise the process\n");
- + exit(EXIT_FAILURE);
- + }
- + if (pid > 0)
- + exit(EXIT_SUCCESS);
- +
- + close(STDIN_FILENO);
- + close(STDOUT_FILENO);
- + close(STDERR_FILENO);
- + }
- +
- + while(run)
- + {
- + if(preDelay)
- + {
- + if(verbose > 0)
- fprintf (stderr, "Pre-delay: %d, sleeping...\n", preDelay);
- - sleep(preDelay);
- +
- + for(int i = 0; i < preDelay; i++)
- + {
- + // allowing camera to adjust exposure
- + uvcGrab(videoIn);
- + videoIn->getPict = 0;
- + sleep(1);
- + }
- }
- if (verbose >= 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement