VS2010中在MFC上使用OpenCV读取视频文件

VS2010中在MFC下使用OpenCV读取视频文件


如下代码可以运行,


void Cs1View::OnVideoFileRead()
	{
		IplImage* pFrame = NULL;  
		//获取视频文件  
		CvCapture *pCapture=cvCreateFileCapture("calib_3D.avi");  
		//cvNamedWindow("video",1);  
		//显示视屏 
		int i=0;
		while(1)  
		{  

			pFrame=cvQueryFrame( pCapture );
			i++;
			CString str;
			str.Format(TEXT("%d"),i); 
		
			if(!pFrame)
				break;
			else
			{
			AfxMessageBox(str);
				i=i+2;
			}
			img1.CopyOf(pFrame);
			Invalidate();
			///*	char c=cvWaitKey(33);  
			//if(c==27)break; */
			//cvReleaseCapture(&pCapture);
			//img1.Destroy();
		}  
	}


但是当将测试使用的AfxMessageBox屏蔽掉,就无法运行,报错,要不就是只能读取一帧,真的太奇怪了。

没有发现错误。

继续调试!