在Visual Studio平台上使用OpenCV C++时播放视频时出错



我试图让它运行,但它什么也没做,没有显示错误,并自动终止了程序。

#include"opencv2/core/core.hpp"
#include"opencv2/highgui/highgui.hpp"
#include"opencv2/imgproc/imgproc.hpp"
#include<stdio.h>
int main(int argc, char* argv)
{
cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE);
CvCapture* capture = cvCreateFileCapture("C:/Users/Nam/Pictures/YALQ6371.MP4");
IplImage* frame;
while (1){
frame = cvQueryFrame(capture);
if (!frame) break;
cvShowImage("Example2", frame);
char c = cvWaitKey(33);
if (c == 27) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("Example2");
return 0;
}

尝试使用imshow而不是cvShowImage,但不要忘记在开始时添加using namespace cv;

最新更新