forked from tTh/FloatImg
first real shoot : [done]
This commit is contained in:
parent
66cd54f3c6
commit
09cbe5b855
|
@ -1,6 +1,6 @@
|
|||
|
||||
|
||||
COPT = -Wall -fpic -g -DDEBUG_LEVEL=1
|
||||
COPT = -Wall -fpic -g -pg -DDEBUG_LEVEL=1
|
||||
DEPS = ../floatimg.h ../libfloatimg.a Makefile
|
||||
|
||||
all: grabvidseq t
|
||||
|
@ -18,7 +18,7 @@ v4l2_pr_structs.o: v4l2_pr_structs.c v4l2_pr_structs.h Makefile
|
|||
gcc ${COPT} -c $<
|
||||
|
||||
grabvidseq: grabvidseq.c Makefile rgb2fimg.o
|
||||
gcc -Wall -g $< rgb2fimg.o ../libfloatimg.a -lv4l2 -o $@
|
||||
gcc ${COPT} $< rgb2fimg.o ../libfloatimg.a -lm -lv4l2 -o $@
|
||||
|
||||
video-infos: video-infos.c Makefile funcs.o v4l2_pr_structs.o
|
||||
gcc -Wall -g $< funcs.o v4l2_pr_structs.o -o $@
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -12,7 +12,7 @@ int iter, size;
|
|||
float *rp, *gp, *bp;
|
||||
|
||||
size = w * h;
|
||||
rp = d->R, gp = d->G, bp = d->G;
|
||||
rp = d->R, gp = d->G, bp = d->B;
|
||||
|
||||
for (iter=0; iter<size; iter++) {
|
||||
*rp++ = (float)*src++;
|
||||
|
|
Loading…
Reference in New Issue