Saving frames in a loop doesn't match framerate

asked 2015-11-14 15:15:17 -0500

jlol gravatar image

Hi, I'm trying to capture some frames using a modified version of a code I found here to read frames from the webcam. My webcam is supposed to be pushing 30fps (measured with outputing (CV_CAP_PROP_FPS)), therefore, this loop would take 1 second, if I understood how webcam methods work, but instead it takes around 5-6 seconds. The original example uses imshow to show the webcam video and it seems to work ok. Am I missing somehting? Should I read the frames in other way?

Mat frame;
std::list<Mat> matList;
while (matList.size() < 30)
    cv_cap >> frame;
    if( frame.empty() ) break; // end of video stream
    matList.push_back(frame); // ---> --Here, actually, I want to do something else, but for this question will work...---
    if( cv::waitKey(1) == 27) break; // stop capturing by pressing ESC ----> --this doesn't work when I press ESC--
edit retag flag offensive close merge delete


The problem got solved, don't know how, maybe was driver related...

jlol gravatar imagejlol ( 2015-12-22 03:03:36 -0500 )edit