Opencv 视频保存 出错 unhandled exception

Opencv 视频保存
编译成功
但是
出现如下的错误
Unhandled exception at 0x5adda400 (highgui200d.dll) in assignment2-3.exe: 0xC0000005: Access violation reading location 0x719b3856.

// assignment2-3.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
//#include "iostream.h"

/*IplImage* doPyrDown(
IplImage* in,
int filter = IPL_GAUSSIAN_5x5)
{

// Best to make sure input image is divisible by two.
//
assert( in->width%2 == 0 && in->height%2 == 0 );

IplImage* out = cvCreateImage(
cvSize( in->width/2, in->height/2 ),
in->depth,
in->nChannels
);
cvPyrDown( in, out );
return( out );
};*/

int main( int argc, char** argv)
{
cvNamedWindow( "assignment2-3", CV_WINDOW_AUTOSIZE );
CvCapture* capture=cvCaptureFromCAM(-1);
CvVideoWriter* video=NULL;

IplImage *frame = cvQueryFrame(capture);
double fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);

CvVideoWriter* writer = cvCreateVideoWriter(
"d:\\w.avi",
-1,fps,
cvSize(frame->width,frame->height)
);

while(1)
{
frame=cvQueryFrame(capture);
if(!frame) break;
cvWriteFrame(writer,frame);
if(cvWaitKey(2)>0) break;
}
cvReleaseVideoWriter(&writer);
//cvReleaseImage(&logpolar_frame);
cvReleaseCapture(&capture);
return(0);
}

我又试过网上其它运行成功的程序
都会出现不同的错误

例如
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"

int main( int argc, char** argv )
{
CvCapture* capture = 0;
IplImage* frame = 0;

//capture = cvCaptureFromCAM( 0 );
capture = cvCaptureFromAVI("d:\\tree.avi");//播放视频 就换成这句

//int fps=25; //捕捉帧率
double fps = cvGetCaptureProperty(capture,CV_CAP_PROP_FPS); //视频帧率

CvVideoWriter* writer = 0; //保存就加上这句
int isColol=1;
int frameW=640;
int frameH=480;
writer=cvCreateVideoWriter("d:\\out.avi",CV_FOURCC('F','L','V','1'),fps,cvSize(frameW,frameH),isColol);

cvNamedWindow( "摄像头", 1 );

//for(int i=0;i<50;i++) //2秒
for(;;) //一直读
{
frame = cvQueryFrame( capture );

cvWriteFrame(writer,frame );

cvShowImage( "摄像头", frame ); //显示一帧图像
cvWaitKey(1000 / fps);//视频速度
}

出现错误是
Unhandled exception at 0x5374530a (opencv_ffmpeg200.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000008.

我的配置是 win7+vc2008 expression +opencv2.0

之前装过 vs2010+opencv2.1 没有删除

不知道是不是系统的问题 还是程序设置的问题

谢谢各位大侠帮我弄清楚吧 下周二交作业
我已经调程序调了一个晚上 从下午7点到现在凌晨五点
就冲我这么用功 也请大侠们帮帮我 快绝望了 先谢谢大家了

第1个回答  2011-02-12
可以试一下openCV1.0,我一般用这个,高版本可能会出问题
第2个回答  2011-02-14
萌萌 自己来!本回答被提问者采纳
相似回答
大家正在搜