I am working through the complexities of the camera device in Linux and so I am starting simple again and here is the framework of a test that times the opening of the video. I thought it was about 6 seconds, but I may have had too much coffee today, as it is 4.260 seconds. This what I want to know, why does it take 5 seconds to connect to the video device and is there any way to shorten the time. Also I want to know what that overhead involves. Clearly it cannot take that long to send a USB query and get a DMA or other ACK, I would assume.
#include <fcntl.h> #include <stdio.h> #include <sys/time.h> suseconds_t time_delta(struct timeval *t0){ struct timeval t; suseconds_t dt; if (t0->tv_sec == 0) gettimeofday(t0, NULL); gettimeofday(&t, NULL); dt = (t.tv_sec - t0->tv_sec)*1000000 + (t.tv_usec - t0->tv_usec); t0->tv_sec = t.tv_sec; t0->tv_usec = t.tv_usec; return dt;} int main( int argc, char * argv[]){ static struct timeval t0 = { 0, 0 }; suseconds_t dt;suseconds_t dt2;int cam_ID; dt = time_delta(&t0); cam_ID = open ("/dev/video0", O_RDWR); dt2 = time_delta(&t0); printf("Camera open ID = %d \ and Open time is %d ms.\n",cam_ID,(dt2-dt)/1000); dt = time_delta(&t0); close (cam_ID); dt2 = time_delta(&t0); printf("Camera close time = %d ms.\n",(dt2-dt)/1000); return 0;}
0 comments:
Post a Comment