1
我有这里的代码来播放视频。当我编译它时,它确实很好,但是当我运行时,它什么都不做。可能是什么问题呢?它是代码吗?还是我的视频依赖不正确安装?使用opencv播放视频
#include <highgui.h>
int main(int argc, char** argv) {
/* Create a window */
cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE);
/* capture frame from video file */
CvCapture* capture = cvCreateFileCapture(argv[1]);
/* Create IplImage to point to each frame */
IplImage* frame;
/* Loop until frame ended or ESC is pressed */
while(1)
{
/* grab frame image, and retrieve */
frame = cvQueryFrame(capture);
/* exit loop if fram is null/movie end */
if(!frame) break;
/* display frame into window */
cvShowImage("Example2", frame);
/* if ESC is pressed then exit loop */
char c = cvWaitKey(33);
if(c==27) break;
}
/* destroy pointer to video */
cvReleaseCapture(&capture);
/* delete window */
cvDestroyWindow("Example2");
return EXIT_SUCCESS;
}
当你运行它时,至少打开了一个窗口? – Niko
不,没有窗口打开。它只是返回到命令行 –
你如何运行它?你告诉它要开什么东西? 首先在while循环中放置一个cout,以查看它是否进入。另外,由于您似乎刚刚开始,我强烈建议您使用openCV2的C++ API。 IplImage来自旧的C API,它的可读性较差并且不易使用。 –