hi I try to play a video file and I get mconfilctig results from the getPropery from VideoCapture Class.
from the get propety frame count in my video I get 31222 frames. But fromthe loop in main, mesauring the i variable I get that there are only 6063 frames? My fps is 30 frames per sec.
So which is right? Maybe the get property gets value from the video file without measuring but by checking the headers of the video? I don't know.Cannot understad why. Using OpenCV 2.4.1 and ubuntu
code:
#include <stdio.h>
#include "cv.h"
#include "highgui.h"
int main( int argc, char** argv )
{
double frameCount;
IplImage *frame;
int key;
/* load the AVI file */
CvCapture *capture = cvCaptureFromAVI( argv[1] );
/* always check */
if( !capture ) return 1;
int i=0;
/* display video */
cvNamedWindow( "video", 0 );
while( key != 'q' ) {
/* get a frame */
frame = cvQueryFrame( capture );
if(!frame){printf("no frame or video finished");}
i++;
/* always check */
if( !frame ) break;
/* display frame */
cvShowImage( "video", frame );
/* quit if user press 'q' */
key = cvWaitKey( 1);
}
frameCount=cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT);
fps = ( int )cvGetCaptureProperty( capture, CV_CAP_PROP_FPS );
printf("fps is %d frames per second\n",fps);
printf("frame count as measured in for loop %d\n",i);
printf("frame count as mesaured from property %f\n",frameCount);
/* free memory */
cvReleaseCapture( &capture );
cvDestroyWindow( "video" );
return 0;
}