period time now in floating point

This commit is contained in:
tth 2019-08-14 19:29:11 +02:00
parent db037c5d12
commit 556522f647

View File

@ -91,15 +91,15 @@ struct timeval tv;
int r, fd = -1;
unsigned int i, n_buffers;
char *dev_name = "/dev/video0";
char out_name[256];
FILE *fout;
struct buffer *buffers;
int foo, bar;
int period = 10; /* delai entre les captures */
double period = 10.0; /* delai entre les captures */
int nbre_capt = 1; /* nombre de captures */
int opt;
double t_debut, t_final;
double t_final;
char *dest_dir = "."; /* no trailing slash */
char *outfile = "out.pnm";
@ -114,13 +114,14 @@ while ((opt = getopt(argc, argv, "d:hn:o:O:p:v")) != -1) {
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 'p': period = 1e6*atof(optarg); break;
case 'v': verbosity++; break;
}
}
if (verbosity) {
fprintf(stderr, "running %s pid=%d\n", argv[0], getpid());
fprintf(stderr, "period is %.3f microseconds\n", period);
}
fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0);
@ -172,7 +173,7 @@ for (n_buffers = 0; n_buffers < req.count; ++n_buffers) {
}
}
t_debut = fimg_timer_set(0);
(void)fimg_timer_set(0);
for (i = 0; i < n_buffers; ++i) {
CLEAR(buf);
@ -218,6 +219,11 @@ for (i = 0; i < nbre_capt; i++) {
return errno;
}
if(verbosity > 1) {
printf("%6d %5.3f\n", i, fimg_timer_get(0));
}
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
@ -253,8 +259,8 @@ for (i = 0; i < nbre_capt; i++) {
out_name);
#endif
if (nbre_capt > 1 && period) {
sleep(period);
if (nbre_capt > 1 && period > 1.0) {
usleep(period);
}
xioctl(fd, VIDIOC_QBUF, &buf);