使用opencv显示视频
根据“使用 opencv 显示视频”,我遇到了一个小问题。该代码是用 Visual Studio 2008 用 C++ 编写的。
代码如下:
int main( int argc, char** argv )
{
cvNamedWindow( "xample2", CV_WINDOW_AUTOSIZE );
CvCapture* capture = cvCreateFileCapture( "Micro-dance_2_.avi" );
IplImage* frame;
while(1) {
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "xample2", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "xample2" );
}
调试时,程序启动,我可以看到命令窗口和一个灰色窗口(我想应该在其中显示视频)几毫秒。然后两个窗口都关闭。
视觉调试窗口的输出显示以下内容:
.. 。 (大量加载和卸载的dll) 。 。 。
程序“[3684] 2aufg4).exe: Native”已退出,代码为 0 (0x0)。
我不知道我做错了什么...
我非常感谢你的帮助!
一如既往地谢谢你们
i have a little problem according "displaying a video with opencv". The code is written in c++ with visual studio 2008.
here is the code:
int main( int argc, char** argv )
{
cvNamedWindow( "xample2", CV_WINDOW_AUTOSIZE );
CvCapture* capture = cvCreateFileCapture( "Micro-dance_2_.avi" );
IplImage* frame;
while(1) {
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "xample2", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "xample2" );
}
when debugging, the programm launches and i can see the command window and a grey window (wher the video should be displayed i suppose) for a few milliseconds. Then both windows close.
the output from debug window in visual shows the following:
..
. (a lot of loaded and unloaded dlls)
.
.
.
The program '[3684] 2aufg4).exe: Native' has exited with code 0 (0x0).
i dont know what i am doing wrong...
i would appreciate your help a lot!
as allways thank you guys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要检查
cvCreateFileCapture()
的返回并确保它成功加载文件:You need to check the return of
cvCreateFileCapture()
and make sure it loaded the file successfully:试试这个
Try this