Search code examples
c++windowsopencvframe-rategcc4.9

How to calculate Frame Per Second in opencv?


Here is my code it display video but at high fps. I want original fps here but don't know how to do it. Watching some tutorials , they are using VideoCapture , I tried to use it but this is giving me linker error undefined reference to 'cv::VideoCapture::VideoCapture(std::string const&)'.. though I am linking all libraries but error is same. I am using Dev-C++ 5.11 (GCC 4.9.2) , so any idea how to use (CV_CAP_PROP_FPS)here -

#include <windows.h>
#include <opencv/cv.hpp>
#include <opencv/highgui.h>
using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
   double fps=0;
   cvNamedWindow( "Movie", CV_WINDOW_NORMAL );
   CvCapture* capture = cvCreateFileCapture( "G:\\movie\\Journey.2.The.Mysterious.Island.2012.avi" );
   IplImage* frame;

   //cv::VideoCapture cap("G:\\movie\\Journey.2.The.Mysterious.Island.2012.avi" ); [giving me error]
   //fps=cap.get(CV_CAP_PROP_FPS); [How to use this]

   while(1)
   {
       frame = cvQueryFrame( capture );
       if( !frame ) break;
       cvShowImage( "Movie", frame );
       char c = cvWaitKey(27);
       if( c == 27 ) break; //esc
   }
   cvReleaseCapture( &capture );
   cvDestroyWindow( "Movie" );
}

Thnx :)


Solution

  • double fps=cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);