?? 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 + -