Often image processing algorithms are benchmarked using frames per second unit. Frames per second indicate the number of frames processed by the program in a second. Here is a short listing for finding the frames per second
#include<highgui.h> #include<cv.h> #include<time.h> #include<stdio.h> #define h 280 #define w 320 using namespace std; int main() { //Start and end times time_t start,end; //Stucture to get feed from cam CvCapture* cap=cvCreateCameraCapture(0); //Windows cvNamedWindow("Cam Feed",CV_WINDOW_AUTOSIZE); //Start the clock time(&start); int counter=0; while(1) { //Getting the present frame IplImage* fram=cvQueryFrame(cap); if(!fram) printf("\nPlease check your webcam connection"); //Showing the frame cvShowImage("Cam Feed",fram); //Stop the clock and show FPS time(&end); ++counter; double sec=difftime(end,start); double fps=counter/sec; printf("\n%lf",fps); //Escape Sequence char c=cvWaitKey(33); if(c==27) break; } //Cleanup cvReleaseCapture(&cap); cvDestroyAllWindows(); }
To find the FPS of video replace cvCreateCameraCapture with cvCreateFileCapture(“Filename”);
Hi, Its Labi Darling…
Look i have set 10frames per sec for my videocam..
now program statement that you wrote is “find the frames per sec” .
but in my program.. result show me 8 frame some time 10 frames .. can you please explain that what does this output mean .. .thanks
Actually FPS does not measure Camera settings, but it measure number of frames program actually processed in one second. It changes from algorithm to algorithm ie., why it is used as a measure of efficiency
Would you tell me how you posted the c++ code in your blog. It looks so nice.
I got it !!! tnx.
Pingback: Object Tracking on the Raspberry Pi with C++, OpenCV, and cvBlob « ProgrammaticPonderings