--- uvccapture-0.5/Makefile 2011-04-17 20:26:22.000000000 +1000
+++ uvccapture-0.5.1/Makefile 2011-09-24 22:28:52.000000000 +1000
@@ -1,7 +1,7 @@
CC=gcc
CPP=g++
APP_BINARY=uvccapture
-VERSION = 0.4
+VERSION = 0.5.1
PREFIX=/usr/local/bin
WARNINGS = -Wall
diff -u uvccapture-0.5/uvccapture.c uvccapture-0.5.1/uvccapture.c
--- uvccapture-0.5/uvccapture.c 2011-04-22 18:19:57.000000000 +1000
+++ uvccapture-0.5.1/uvccapture.c 2011-09-23 22:25:19.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");
@@ -73,11 +75,13 @@
fprintf (stderr, "-m\t\tToggles capture mode to YUYV capture\n");
fprintf (stderr,
"-D<integer>\tPre-delay before capture\n");
/* fprintf (stderr, "Camera Settings:\n");
+ fprintf (stderr,
+ "-W\t\tConstantly capture images during the pre-delay loop\n");
+ fprintf (stderr, "Camera Settings:\n");
fprintf (stderr, "-B<integer>\tBrightness\n");
fprintf (stderr, "-C<integer>\tContrast\n");
fprintf (stderr, "-S<integer>\tSaturation\n");
fprintf (stderr, "-G<integer>\tGain\n");*/
exit (8);
}
@@ -299,6 +303,8 @@
unsigned char* imageWithDHT = NULL;
int imageWithDHTSize = 0;
int preDelay = 0;
+ boolean backGround = FALSE;
+ boolean preDelayCapture = FALSE;
(void) signal (SIGINT, sigcatch);
(void) signal (SIGQUIT, sigcatch);
@@ -325,6 +331,10 @@
snprintf(outputfile, MAXFILENAMELENGTH, "%s", &argv[1][2]);
break;
+ case 'b':
+ backGround = TRUE;
+ break;
+
case 'd':
videodevice = &argv[1][2];
break;
@@ -357,6 +367,10 @@
post_capture_command_wait = 1;
break;
+ case 'W':
+ preDelayCapture = TRUE;
+ break;
+
case 'B':
brightness = atoi (&argv[1][2]);
break;
@@ -410,6 +424,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 +474,45 @@
} else if (verbose >= 1) {
fprintf (stderr, "Camera gain level is %d\n",
v4l2GetControl (videoIn, V4L2_CID_GAIN));
}*/
ref_time = time (NULL);
+ 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 ) {
- // allowing camera to adjust exposure
- uvcGrab(videoIn);
- videoIn->getPict = 0;
- if (verbose >= 0)
+ if (preDelay) {
+ if (verbose > 0)
fprintf (stderr, "Pre-delay: %d, sleeping...\n", preDelay);
- sleep(preDelay);
+
+ for (int i = 0; i < preDelay; i++) {
+ if(run == 0)
+ break;
+ // allowing camera to adjust exposure
+ if (i == 0 || preDelayCapture) {
+ uvcGrab(videoIn);
+ videoIn->getPict = 0;
+ }
+
+ sleep(1);
+ }
}
if (verbose >= 2)