Very Low FPS Problem " Always 5 fps "
Hi everyone ,
I have good webcam " Logiteck C920 ", when i run any of my opencv programs i got just 5 fps.
I searched on the internet and i found that the computing inside the while loop slows down the fps.
So i tried a simple webcam program and i still got 5 fps , any help please to get a normal fps
i fond in the internet that many people got 16-30 fps easily with this webcam without any problem.
My webcam code simplified:
int main(int argc, char* argv[])
{
VideoCapture cap(0); // open the video camera no. 0
Mat save_img; cap >> save_img;
//reduce computing by disabling the rgb conversion
cap.set(CV_CAP_PROP_CONVERT_RGB , false);
cap.set(CV_CAP_PROP_FPS , 60);
if (!cap.isOpened()) // if not success, exit program
{
cout << "Cannot open the video cam" << endl;
return -1;
}
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
while (1)
{
Mat frame;
cap.retrieve(frame);
cout << "\n " << CV_CAP_PROP_FPS << "\n " ;
imshow("MyVideo", frame); //show the frame in "MyVideo" window
Mat save_img; cap >> save_img;
if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
{
imwrite("test.jpg", save_img);
cout << "esc key is pressed by user" << endl;
break;
}
}
return 0;
}
Thank you
Cheers
I do not know if this is helpful but waitKey(30) may be a little too much, try 10 instead...
Another thing, if you open the camera does it run at more than 30 fps?
@thdrksdfthmn i tried waitKey(10) , same issue :( when i run the camera with another program "vlc" it run at 30fps
have you done as Haris said:
cout << "\n " << cap.get(CV_CAP_PROP_FPS) << "\n " ;
? What is it printing?