Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added command line option to specify number of images to capture. Aft…

…er capturing the specified images the program will exit.
  • Loading branch information...
commit 4b8bc5b2fbfbd65ada013757682d64d0d2cc9256 1 parent 0f7a8e2
Alexandru Csete authored
Showing with 11 additions and 4 deletions.
  1. +3 −2 README
  2. +0 −1  TODO
  3. +8 −1 uvccapture.c
5 README
View
@@ -2,8 +2,9 @@ Uvccapture is a simple application for capturing images from an USB webcam on
Linux. This repository contains my fork and hacks on uvccapture.
My modificantions include:
-- Sequential numbering of files (img001.jpg, img002.jpg, ...)
-- Allow capturing JPG format any resolution supported by the camera. The
+- Sequential numbering of files (img001.jpg, img002.jpg, ...).
+- Command line option for number of images to capture.
+- Allow capturing JPG format at any resolution supported by the camera. The
original uvccapture switches to YUYV mode at resolution 960x720 and higher,
while many cameras support MJPG at full resolution.
- Allow capture rates higher that 1 frame per second.
1  TODO
View
@@ -1,4 +1,3 @@
-* Command line option for number of snapshots, e.g. -n20
* Better management and error checking on command line options
* Check whether camera supports jpeg at requested resolution.
* Add support for manual focus
9 uvccapture.c
View
@@ -62,6 +62,8 @@ void usage (void)
fprintf (stderr,
"-t<integer>\tTake continuous shots with <integer> seconds between them (0 for single shot)\n");
fprintf (stderr,
+ "-n<integer>\tTake <integer> shots then exit. Only applicable when delay is non-zero\n");
+ fprintf (stderr,
"-q<percentage>\tJPEG Quality Compression Level (activates YUYV capture)\n");
fprintf (stderr, "-r\t\tUse read instead of mmap for image capture\n");
fprintf (stderr,
@@ -189,6 +191,7 @@ int main (int argc, char *argv[])
int width = 320;
int height = 240;
int brightness = 0, contrast = 0, saturation = 0, gain = 0;
+ int num = 1; /* number of images to capture */
int verbose = 0;
int delay = 0;
int quality = 95;
@@ -246,6 +249,10 @@ int main (int argc, char *argv[])
format = V4L2_PIX_FMT_YUYV;
break;
+ case 'n':
+ num = atoi (&argv[1][2]);
+ break;
+
case 't':
delay = atoi (&argv[1][2]);
break;
@@ -410,7 +417,7 @@ int main (int argc, char *argv[])
ref_time = time (NULL);
}
- if (delay == 0)
+ if ((delay == 0) || (num == i))
break;
}
close_v4l2 (videoIn);
Please sign in to comment.
Something went wrong with that request. Please try again.