View difference between Paste ID: VyARaPG0 and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
1 | + | diff -u uvccapture-0.5/Makefile uvccapture-0.5.1/Makefile |
2 | --- uvccapture-0.5/Makefile 2011-04-17 20:26:22.000000000 +1000 | |
3 | +++ uvccapture-0.5.1/Makefile 2011-09-23 21:27:26.000000000 +1000 | |
4 | @@ -1,8 +1,8 @@ | |
5 | CC=gcc | |
6 | CPP=g++ | |
7 | APP_BINARY=uvccapture | |
8 | -VERSION = 0.4 | |
9 | -PREFIX=/usr/local/bin | |
10 | +VERSION = 0.5.1 | |
11 | +PREFIX=/usr/bin | |
12 | ||
13 | WARNINGS = -Wall | |
14 | ||
15 | diff -u uvccapture-0.5/uvccapture.c uvccapture-0.5.1/uvccapture.c | |
16 | --- uvccapture-0.5/uvccapture.c 2011-04-22 18:19:57.000000000 +1000 | |
17 | +++ uvccapture-0.5.1/uvccapture.c 2011-09-23 22:25:19.000000000 +1000 | |
18 | @@ -58,6 +58,8 @@ | |
19 | fprintf (stderr, "-o<filename>\tOutput filename(default: snap.jpg)\n"); | |
20 | fprintf (stderr, "-d<device>\tV4L2 Device(default: /dev/video0)\n"); | |
21 | fprintf (stderr, | |
22 | + "-b\t\tRun in the background\n"); | |
23 | + fprintf (stderr, | |
24 | "-x<width>\tImage Width(must be supported by device)\n"); | |
25 | fprintf (stderr, | |
26 | "-y<height>\tImage Height(must be supported by device)\n"); | |
27 | @@ -73,11 +75,13 @@ | |
28 | fprintf (stderr, "-m\t\tToggles capture mode to YUYV capture\n"); | |
29 | fprintf (stderr, | |
30 | "-D<integer>\tPre-delay before capture\n"); | |
31 | /* fprintf (stderr, "Camera Settings:\n"); | |
32 | + fprintf (stderr, | |
33 | + "-W\t\tConstantly capture images during the pre-delay loop\n"); | |
34 | + fprintf (stderr, "Camera Settings:\n"); | |
35 | fprintf (stderr, "-B<integer>\tBrightness\n"); | |
36 | fprintf (stderr, "-C<integer>\tContrast\n"); | |
37 | fprintf (stderr, "-S<integer>\tSaturation\n"); | |
38 | fprintf (stderr, "-G<integer>\tGain\n");*/ | |
39 | exit (8); | |
40 | } | |
41 | ||
42 | @@ -299,6 +303,8 @@ | |
43 | unsigned char* imageWithDHT = NULL; | |
44 | int imageWithDHTSize = 0; | |
45 | int preDelay = 0; | |
46 | + boolean backGround = FALSE; | |
47 | + boolean preDelayCapture = FALSE; | |
48 | ||
49 | (void) signal (SIGINT, sigcatch); | |
50 | (void) signal (SIGQUIT, sigcatch); | |
51 | @@ -325,6 +331,10 @@ | |
52 | snprintf(outputfile, MAXFILENAMELENGTH, "%s", &argv[1][2]); | |
53 | break; | |
54 | ||
55 | + case 'b': | |
56 | + backGround = TRUE; | |
57 | + break; | |
58 | + | |
59 | case 'd': | |
60 | videodevice = &argv[1][2]; | |
61 | break; | |
62 | @@ -357,6 +367,10 @@ | |
63 | post_capture_command_wait = 1; | |
64 | break; | |
65 | ||
66 | + case 'W': | |
67 | + preDelayCapture = TRUE; | |
68 | + break; | |
69 | + | |
70 | case 'B': | |
71 | brightness = atoi (&argv[1][2]); | |
72 | break; | |
73 | @@ -410,6 +424,10 @@ | |
74 | if (post_capture_command[0]) | |
75 | fprintf (stderr, "Executing '%s' after each image capture\n", | |
76 | post_capture_command[0]); | |
77 | + if (backGround) | |
78 | + fprintf (stderr, "Will switch to run in the background\n"); | |
79 | + else | |
80 | + fprintf (stderr, "Will not switch to run in the background\n"); | |
81 | } | |
82 | videoIn = (struct vdIn *) calloc (1, sizeof (struct vdIn)); | |
83 | if (init_videoIn | |
84 | @@ -456,17 +474,45 @@ | |
85 | } else if (verbose >= 1) { | |
86 | fprintf (stderr, "Camera gain level is %d\n", | |
87 | v4l2GetControl (videoIn, V4L2_CID_GAIN)); | |
88 | }*/ | |
89 | ref_time = time (NULL); | |
90 | ||
91 | + if(backGround) | |
92 | + { | |
93 | + if(verbose > 0) | |
94 | + fprintf (stderr, "starting the daemonising process\n"); | |
95 | + | |
96 | + verbose = 0; | |
97 | + pid_t pid = fork(); | |
98 | + if(pid < 0) | |
99 | + { | |
100 | + fprintf (stderr, "Unable to daemonise the process\n"); | |
101 | + exit(EXIT_FAILURE); | |
102 | + } | |
103 | + if (pid > 0) | |
104 | + exit(EXIT_SUCCESS); | |
105 | + | |
106 | + close(STDIN_FILENO); | |
107 | + close(STDOUT_FILENO); | |
108 | + close(STDERR_FILENO); | |
109 | + } | |
110 | + | |
111 | while (run) { | |
112 | - if( preDelay ) { | |
113 | - // allowing camera to adjust exposure | |
114 | - uvcGrab(videoIn); | |
115 | - videoIn->getPict = 0; | |
116 | - if (verbose >= 0) | |
117 | + if (preDelay) { | |
118 | + if (verbose > 0) | |
119 | fprintf (stderr, "Pre-delay: %d, sleeping...\n", preDelay); | |
120 | - sleep(preDelay); | |
121 | + | |
122 | + for (int i = 0; i < preDelay; i++) { | |
123 | + if(run == 0) | |
124 | + break; | |
125 | + // allowing camera to adjust exposure | |
126 | + if (i == 0 || preDelayCapture) { | |
127 | + uvcGrab(videoIn); | |
128 | + videoIn->getPict = 0; | |
129 | + } | |
130 | + | |
131 | + sleep(1); | |
132 | + } | |
133 | } | |
134 | ||
135 | if (verbose >= 2) |