first real shoot : [done]
This commit is contained in:
@@ -32,8 +32,9 @@
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* compilation control */
|
||||
|
||||
#define SAVE_AS_CUMUL 1
|
||||
#define SAVE_AS_PNM 0
|
||||
#define SAVE_AS_FIMG 1
|
||||
#define SAVE_AS_FIMG 0
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
@@ -74,6 +75,7 @@ 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-o bla\t\tset oputput filename");
|
||||
puts("\t-p NNN\t\tperiod in seconds");
|
||||
puts("\t-v\t\tincrease verbosity");
|
||||
exit(0);
|
||||
@@ -101,13 +103,19 @@ int nbre_capt = 1; /* nombre de captures */
|
||||
int opt;
|
||||
double t_debut, t_final;
|
||||
char *dest_dir = "."; /* no trailing slash */
|
||||
char *outfile = "out.pnm";
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:hn:O:p:v")) != -1) {
|
||||
#if SAVE_AS_CUMUL
|
||||
FloatImg grab, cumul;
|
||||
#endif
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:hn:o: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 'o': outfile = optarg; break;
|
||||
case 'p': period = atoi(optarg); break;
|
||||
case 'v': verbosity++; break;
|
||||
}
|
||||
@@ -176,6 +184,16 @@ for (i = 0; i < n_buffers; ++i) {
|
||||
xioctl(fd, VIDIOC_QBUF, &buf);
|
||||
}
|
||||
|
||||
#if SAVE_AS_CUMUL
|
||||
foo = fimg_create(&grab,
|
||||
fmt.fmt.pix.width, fmt.fmt.pix.height,
|
||||
FIMG_TYPE_RGB);
|
||||
foo = fimg_create(&cumul,
|
||||
fmt.fmt.pix.width, fmt.fmt.pix.height,
|
||||
FIMG_TYPE_RGB);
|
||||
fimg_clear(&cumul);
|
||||
#endif
|
||||
|
||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
xioctl(fd, VIDIOC_STREAMON, &type);
|
||||
|
||||
@@ -205,7 +223,6 @@ for (i = 0; i < nbre_capt; i++) {
|
||||
xioctl(fd, VIDIOC_DQBUF, &buf);
|
||||
|
||||
#if SAVE_AS_PNM
|
||||
|
||||
/* at this time,we'v got a picture in-memory,
|
||||
so we can blast in on storage */
|
||||
sprintf(out_name, "%s/%05d.ppm", dest_dir, i);
|
||||
@@ -219,7 +236,12 @@ for (i = 0; i < nbre_capt; i++) {
|
||||
fmt.fmt.pix.width, fmt.fmt.pix.height);
|
||||
fwrite(buffers[buf.index].start, buf.bytesused, 1, fout);
|
||||
fclose(fout);
|
||||
#endif
|
||||
|
||||
#if SAVE_AS_CUMUL
|
||||
x_rgb2fimg(buffers[buf.index].start,
|
||||
fmt.fmt.pix.width, fmt.fmt.pix.height, &grab);
|
||||
fimg_add(&grab, &cumul, &cumul);
|
||||
#endif
|
||||
|
||||
#if SAVE_AS_FIMG
|
||||
@@ -239,6 +261,15 @@ for (i = 0; i < nbre_capt; i++) {
|
||||
|
||||
t_final = fimg_timer_get(0);
|
||||
fprintf(stderr, "pid %d : elapsed time %g s\n", getpid(), t_final);
|
||||
fprintf(stderr, "\t%.2f fps\n", (double)nbre_capt / t_final);
|
||||
|
||||
#if SAVE_AS_CUMUL
|
||||
// save cumul to file
|
||||
foo = fimg_save_as_pnm(&cumul, outfile, 0);
|
||||
// free buffers
|
||||
fimg_destroy(&grab);
|
||||
fimg_destroy(&cumul);
|
||||
#endif
|
||||
|
||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
xioctl(fd, VIDIOC_STREAMOFF, &type);
|
||||
|
||||
Reference in New Issue
Block a user