我使用OpenCV中捕捉來自攝像機的視頻和存儲和avi文件,問題是,當我完成捕獲和運行AVI文件,視頻流看上去笨拙快...OpenCV,捕獲的視頻比原始攝像機視頻運行得更快!
這裏是代碼
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");
}
請幫助
您的建議對我來說似乎合理,但是您能否更清楚地表達您的意思:「您可以嘗試先捕獲視頻,在發生時測量實際的FPS,然後使用該視頻編寫AVI值。>> – 2010-12-03 17:16:43