This is probably an open-ended question. I have written an opencv application that captures feed from two external cameras connected to the computer. The capture from both the cameras runs parallely on 2 different threads. This recorder module writes the frames to a video file which is later processed. The following code sits inside each thread function:
CvCapture *capture =cvCaptureFromCAM(indexOfCamera);
if(!capture) return;
CvSize sz =cvGetSize(cvQueryFrame(capture));
cvNamedWindow("src");
CvVideoWriter *writer =cvCreateVideoWriter((char*) p, CV_FOURCC('L','A','G','S'), 20, sz);
if( !writer ) {
cvReleaseCapture( &capture );
return;
}
IplImage *frame;
int frameCounter =0;
while(true){
QueryPerformanceCounter(&sideCamCounter);
frame =cvQueryFrame(capture);
if(!frame)break;
//Store timestamp of frame somewhere
cvShowImage("src", frame);
cvWriteFrame(writer, frame);
int c=cvWaitKey(1);
if((char)c ==27)break;
++frameCounter;
}
cvReleaseVideoWriter(&writer);
cvReleaseCapture(&capture);
cvDestroyAllWindows();
The two cameras I am using are: A - Microsoft hd-6000 lifecam for notebooks and B - Logitech sphere AF webcam. Camera A captures at around 16-20 fps(reaches upto 30 fps during a few recordings) and camera B captures at around 10-12 fps.
I need a faster capture rate to be able to capture real-time motion. I understand I will be limited by the camera's capture speed/rate but apart from that, what other factors will affect the capture rate - e.g. load on the system(Memory and CPU), the API's used ? I am open to explore options. Thanks.
Try to set different camera properties - http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-set, probably the most interesting for you will be... FPS :) Note that it's not always working fine ( How to set camera FPS in OpenCV? CV_CAP_PROP_FPS is a fake ), but give it a chance, maybe it will help you. Also you may try to set smaller image resolution.
If you don't have to - don't display image.
I don't think it will help, but if you want you may try to use different API - OpenCV on Mac is not opening USB web camera