Ask Your Question
1

Very Low FPS Problem " Always 5 fps "

asked 2014-08-08 08:24:49 -0600

Anna Lina gravatar image

updated 2015-09-19 11:22:59 -0600

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

edit retag flag offensive close merge delete

Comments

I do not know if this is helpful but waitKey(30) may be a little too much, try 10 instead...

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-08-08 10:10:47 -0600 )edit

Another thing, if you open the camera does it run at more than 30 fps?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-08-08 10:14:38 -0600 )edit

@thdrksdfthmn i tried waitKey(10) , same issue :( when i run the camera with another program "vlc" it run at 30fps

Anna Lina gravatar imageAnna Lina ( 2014-08-12 08:21:26 -0600 )edit

have you done as Haris said: cout &lt;&lt; "\n " &lt;&lt; cap.get(CV_CAP_PROP_FPS) &lt;&lt; "\n " ;? What is it printing?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-08-12 08:24:32 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-08-08 10:06:27 -0600

Haris gravatar image

updated 2014-08-08 10:07:53 -0600

The line cout CV_CAP_PROP_FPS " will print the value of MACRO CV_CAP_PROP_FPS which may be 5, instead you need to use cap.get(CV_CAP_PROP_FPS) to get the frame rate.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-08-08 08:24:49 -0600

Seen: 2,907 times

Last updated: Aug 08 '14