forked from tTh/FloatImg
cumul image can be converted to gray
This commit is contained in:
parent
cc6dd330ed
commit
f0c704a818
@ -71,6 +71,7 @@ if (verbosity) {
|
||||
}
|
||||
puts("options :");
|
||||
puts("\t-d /dev/?\tselect video device");
|
||||
puts("\t-g\t\tconvert to gray");
|
||||
puts("\t-n NNN\t\thow many frames ?");
|
||||
puts("\t-O ./\t\tset Output dir");
|
||||
puts("\t-o bla\t\tset output filename");
|
||||
@ -103,6 +104,7 @@ int opt;
|
||||
int width = 640;
|
||||
int height = 480;
|
||||
double t_final;
|
||||
int to_gray = 0;
|
||||
char *dest_dir = "."; /* no trailing slash */
|
||||
char *outfile = "out.pnm";
|
||||
|
||||
@ -110,9 +112,10 @@ char *outfile = "out.pnm";
|
||||
FloatImg grab, cumul;
|
||||
#endif
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:hn:o:O:p:s:v")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "d:ghn:o:O:p:s:v")) != -1) {
|
||||
switch(opt) {
|
||||
case 'd': dev_name = optarg; break;
|
||||
case 'g': to_gray = 1; break;
|
||||
case 'h': help(0); break;
|
||||
case 'n': nbre_capt = atoi(optarg); break;
|
||||
case 'O': dest_dir = optarg; break;
|
||||
@ -143,6 +146,7 @@ fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
|
||||
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
||||
xioctl(fd, VIDIOC_S_FMT, &fmt);
|
||||
if (fmt.fmt.pix.pixelformat != V4L2_PIX_FMT_RGB24) {
|
||||
/* are others formats usable ? */
|
||||
printf("Libv4l didn't accept RGB24 format. Can't proceed.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -197,11 +201,10 @@ foo = fimg_create(&cumul,
|
||||
FIMG_TYPE_RGB);
|
||||
fimg_clear(&cumul);
|
||||
cumul.fval = 255.0;
|
||||
cumul.count = 0;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
xioctl(fd, VIDIOC_STREAMON, &type);
|
||||
|
||||
@ -282,6 +285,10 @@ 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
|
||||
if (to_gray) {
|
||||
if (verbosity) fputs("converting to gray\n", stderr);
|
||||
foo = fimg_to_gray(&cumul);
|
||||
}
|
||||
// save cumul to file
|
||||
foo = fimg_save_as_pnm(&cumul, outfile, 0);
|
||||
// free buffers
|
||||
|
Loading…
Reference in New Issue
Block a user