📄 cam_time2.c
字号:
#include "cam.h"#include <sys/poll.h>#include <sys/time.h>#include <time.h>int main() { struct timeval tv, tvo; double t; struct cam c1, c2; cam_init(&c1, 0); cam_init(&c2, 1); gettimeofday(&tvo, NULL); cam_capture(&c1); cam_capture(&c2); struct pollfd ufds[2] = {{c1.fd, POLLIN},{c2.fd, POLLIN}}; int i = 0; for (; i<300; ++i) { if (poll(ufds, 2, -1) <= 0) { fprintf(stderr, "poll error\n"); return -1; } if (ufds[0].revents & POLLIN) { cam_sync(&c1); gettimeofday(&tv, NULL); t = tv.tv_sec - tvo.tv_sec; t += (double)(tv.tv_usec - tvo.tv_usec) / 1e6; tvo = tv; printf("%f\t", t); cam_capture(&c1); } if (ufds[1].revents & POLLIN) { cam_sync(&c2); gettimeofday(&tv, NULL); t = tv.tv_sec - tvo.tv_sec; t += (double)(tv.tv_usec - tvo.tv_usec) / 1e6; tvo = tv; printf("%f\n", t); cam_capture(&c2); } } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -