I'm capturing PS3 Eye Camera Video to images which i resize and display as well as saving them to disk. I had troubles with framerates so i measured time with each individual process. It turns out that the only process really slowing down the capturing is cvWaitKey(1) which adds some 20 milliseconds to each capture loop.
Is there a workaround to avoid cvWaitKey() in some way ?
The times measured will be about 20ms without the waitkey and display and 60ms with displaying (which waitkey is needed for). Resizing does not add a this significant amount of time.
Thanks for any help.
// image capturing loop
while(_running)
{
//activate cvWaitKey - this drops framerate significantly!
cvWaitKey(1);
//get frame from capture and put into buffer
CLEyeCameraGetFrame(_cam, pCapBuffer);
//get system timestamps
GetSystemTime(&st);
GetLocalTime(<);
// Resize image to fit screen size
cvResize(pCapImage,resizedpCapImage,CV_INTER_NN);
//display image
cvShowImage(_windowName, resizedpCapImage);
//clear string
sstm.str(std::string());
//complete filname
sstm << _folder << prefix << _participant << std::setfill('0') << std::setw(10) << i << "-" << st.wHour << st.wMinute << st.wSecond << st.wMilliseconds << suffix;
image_name = sstm.str();
c = image_name.c_str();
//log if enabled
if (_logging){
//try to save image
try {
cvSaveImage(c, pCapImage); //bmp = speed!
}
catch (runtime_error& ex) {
fprintf(stderr, "Exception converting image to bmp format: %s\n", ex.what());
}
}
}