cam_time1.c

来自「足球机器人自动程序」· C语言 代码 · 共 41 行

C
41
字号
#include "cam.h"#include <sys/poll.h>#include <sys/time.h>#include <time.h>int main() {	struct timeval tv, tvo;	double t;	struct cam c;	cam_init(&c, 0);	gettimeofday(&tvo, NULL);	cam_capture(&c);	struct pollfd ufds = {c.fd, POLLIN};	int i = 0;	for (; i<300; ++i) {		if (poll(&ufds, 1, -1) <= 0) {			fprintf(stderr, "poll error\n");			return -1;		}		cam_sync(&c);		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(&c);	}	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?