Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

FPS for USB WEB cam

Please help me. I'am beginer? and i undestend :(

For this code (win 7) i have only about 6.8 FPS. i need 25. How to сapture at higher FPS. thank you.

cap.get(CV_CAP_PROP_FPS)=0

int main() 
    {
        VideoCapture cap(0); // open the video file for reading

        if ( !cap.isOpened() )  // if not success, exit program
        {
             cout << "Cannot open the video file" << endl;
             return -1;
        }

        double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
        if (fps==0) 
        {
            fps=25;   
        }

        cout << "Frame per seconds : " << fps << endl;
        CvSize size = cvSize( cap.get( CV_CAP_PROP_FRAME_WIDTH), cap.get(  CV_CAP_PROP_FRAME_HEIGHT));
        VideoWriter writer = VideoWriter("cap.avi",CV_FOURCC('M','J','P','G'), fps, size, 1);

        int cc=0;

        while(1)
        {
            Mat frame;

            bool bSuccess = cap.read(frame); // read a new frame from video

            if (!bSuccess) //if not success, break loop
            {
                            cout << "Cannot read the frame from video file" << endl;
                           break;
            }
            writer.write(frame);

            cc++;

            if(waitKey(1) == 27) 

           {
                    cout << "esc key is pressed by user" << endl; 
                    cout << cc << endl; 
                    waitKey(10000) ;
                     break; 
           }
        }
        writer.release();
        return 0;
    }

FPS for USB WEB cam

Please help me. I'am beginer? and i undestend :(

For this code (win 7) i have only about 6.8 FPS. i need 25. How to сapture at higher FPS. thank you.

cap.get(CV_CAP_PROP_FPS)=0

int main() 
    {
        VideoCapture cap(0); // open the video file for reading

        if ( !cap.isOpened() )  // if not success, exit program
        {
             cout << "Cannot open the video file" << endl;
             return -1;
        }

        double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
        if (fps==0) 
        {
            fps=25;   
        }

        cout << "Frame per seconds : " << fps << endl;
        CvSize size = cvSize( cap.get( CV_CAP_PROP_FRAME_WIDTH), cap.get(  CV_CAP_PROP_FRAME_HEIGHT));
        VideoWriter writer = VideoWriter("cap.avi",CV_FOURCC('M','J','P','G'), fps, size, 1);

        int cc=0;

        while(1)
        {
            Mat frame;

            bool bSuccess = cap.read(frame); // read a new frame from video

            if (!bSuccess) //if not success, break loop
            {
                            cout << "Cannot read the frame from video file" << endl;
                           break;
            }
            writer.write(frame);

            cc++;

            if(waitKey(1) == 27) 

           {
                    cout << "esc key is pressed by user" << endl; 
                    cout << cc << endl; 
                    waitKey(10000) ;
                     break; 
           }
        }
        writer.release();
        return 0;
    }