ajout d'un chronometre

This commit is contained in:
Tonton Th 2019-05-28 12:10:55 +02:00
parent b5016d74e6
commit 862ab2a30e
3 changed files with 9 additions and 2 deletions

2
.gitignore vendored
View File

@ -13,7 +13,7 @@ essai
v4l2/t
v4l2/capture
v4l2/v4l2grab
v4l2/grabvidseq
v4l2/*.o
v4l2/*.ppm

View File

@ -16,6 +16,6 @@ capture: capture.c Makefile
gcc -Wall -g $< -o $@
grabvidseq: grabvidseq.c Makefile
gcc -Wall -g $< -lv4l2 -o $@
gcc -Wall -g $< ../libfloatimg.a -lv4l2 -o $@

View File

@ -26,6 +26,8 @@
#include <linux/videodev2.h>
#include <libv4l2.h>
#include "../floatimg.h"
#define CLEAR(x) memset(&(x), 0, sizeof(x))
struct buffer {
@ -80,6 +82,7 @@ struct buffer *buffers;
int period = 10; /* delai entre les captures */
int nbre_capt = 1; /* nombre de captures */
int opt;
double t_debut, t_final;
while ((opt = getopt(argc, argv, "d:hn:p:v")) != -1) {
switch(opt) {
@ -142,6 +145,7 @@ for (n_buffers = 0; n_buffers < req.count; ++n_buffers) {
}
}
t_debut = fimg_timer_set(0);
for (i = 0; i < n_buffers; ++i) {
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@ -194,6 +198,9 @@ for (i = 0; i < nbre_capt; i++) {
xioctl(fd, VIDIOC_QBUF, &buf);
}
t_final = fimg_timer_get(0);
fprintf(stderr, "elapsed time %g s.\n", t_final);
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
xioctl(fd, VIDIOC_STREAMOFF, &type);
for (i = 0; i < n_buffers; ++i) {