i need to take one frame for second with OpenCV. The problem is that VideoCapture::get(CV_CAP_PROP_FPS); always returns 0. And if i try to set the desired fps with VideoCapture::set nothing change.
This is my code:
VideoCapture cap(0); if (!cap.isOpened()) { cout << "Cannot open the video cam" << endl; return -1; } double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); double fps = 1; cap.set(CV_CAP_PROP_FPS, fps); cout << "FPS : " << fps << endl; cout << "Frame size : " << dWidth << " x " << dHeight << endl; namedWindow("CAPTURE EXPRESSION",CV_WINDOW_AUTOSIZE); while (1) { Mat frame; bool bSuccess = cap.read(frame); if (!bSuccess) { cout << "Cannot read a frame from video stream" << endl; break; } fps = cap.get(CV_CAP_PROP_FPS); imshow("MyVideo", frame); cout << "FPS : " << fps << endl; if (waitKey(30) == 27) { cout << "esc key is pressed by user" << endl; break; } } P.S. i'm using OpenCV 2.4.9 with a Mac OS, and with the integrated camera of the MacBook