Browse Source

we can select the output directory

master
Tonton Th 3 years ago
parent
commit
503c40f6df
  1. 9
      v4l2/grabvidseq.c

9
v4l2/grabvidseq.c

@ -58,6 +58,7 @@ void help(int v) @@ -58,6 +58,7 @@ void help(int v)
puts("options :");
puts("\t-d /dev/?\tselect video device");
puts("\t-n NNN\t\thow many frames ?");
puts("\t-O ./\t\tset Output dir");
puts("\t-p NNN\t\tperiod in seconds");
puts("\t-v\t\tincrease verbosity");
exit(0);
@ -83,12 +84,14 @@ int period = 10; /* delai entre les captures */ @@ -83,12 +84,14 @@ int period = 10; /* delai entre les captures */
int nbre_capt = 1; /* nombre de captures */
int opt;
double t_debut, t_final;
char dest_dir = ""; /* must have the trailing slash */
while ((opt = getopt(argc, argv, "d:hn:p:v")) != -1) {
while ((opt = getopt(argc, argv, "d:hn:O:p:v")) != -1) {
switch(opt) {
case 'd': dev_name = optarg; break;
case 'h': help(0); break;
case 'n': nbre_capt = atoi(optarg); break;
case 'O': dest_dir = optarg; break;
case 'p': period = atoi(optarg); break;
case 'v': verbosity++; break;
}
@ -179,7 +182,7 @@ for (i = 0; i < nbre_capt; i++) { @@ -179,7 +182,7 @@ for (i = 0; i < nbre_capt; i++) {
buf.memory = V4L2_MEMORY_MMAP;
xioctl(fd, VIDIOC_DQBUF, &buf);
sprintf(out_name, "out%03d.ppm", i);
sprintf(out_name, "%s/%05d.ppm", dest_dir, i);
if (verbosity) fprintf(stderr, "--> %s\n", out_name);
fout = fopen(out_name, "w");
@ -199,7 +202,7 @@ for (i = 0; i < nbre_capt; i++) { @@ -199,7 +202,7 @@ for (i = 0; i < nbre_capt; i++) {
}
t_final = fimg_timer_get(0);
fprintf(stderr, "elapsed time %g s.\n", t_final);
fprintf(stderr, "elapsed time %g s\n", t_final);
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
xioctl(fd, VIDIOC_STREAMOFF, &type);

Loading…
Cancel
Save