OpenCV captured video is faster than the original video camera!

I use openCV to capture video from the camera and save to avi file and file, the problem is that when I finish capturing and running the avi file, the video stream looks awkwardly fast ...

here is the code

void main( )
{
CvCapture *capture = cvCaptureFromCAM( 0 );

int width = ( int )cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH );
int height = ( int )cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT );
CvVideoWriter *writer = cvCreateVideoWriter( "myCamCapture.avi",
-1,30, cvSize(  width, height ) );
cvNamedWindow("d", CV_WINDOW_AUTOSIZE);
IplImage *frame = 0;


while( 1 )
{
    frame = cvQueryFrame( capture );

    cvShowImage("d",frame);
    cvWriteFrame( writer, frame );
    char c = cvWaitKey( 33 );
    if( c == 27 ) break;
}

cvReleaseCapture( &capture );
cvReleaseVideoWriter( &writer );
cvDestroyWindow( "d" );


    }

please, help

+3
source share
2 answers

You tell the author that he should play at 30 frames per second. So if you really capture, say, 15 frames per second, these frames will play back faster than in real time.

, , . . , FPS , AVI, .

+3

cvGetCaptureProperty (CV_CAP_PROP_FPS), , , 1000/fps 33 .

+1

Source: https://habr.com/ru/post/1778347/


All Articles