`
haibuo1981
  • 浏览: 50594 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

OpenCV的imshow无法正常显示视频

阅读更多
OpenCV2.2,vs2010,win7

程序读一段视频,然后进行分析处理,在显示视频的时候,却发现imshow无法显示读取的帧。代码如下:
VideoCapture cap;
cap.open("test.avi");
namedWindow("video",1);
for(;;){
 Mat frame;
 cap<<frame;
 if(frame.empty())
	break;
 imshow("video",frame);
 //waitKey(30)
}


跟踪了一下,发现确实是读入了帧,只是在显示的时候没有出来。
在网上查了下文档,原来是循环中,highgui没有给予imshow绘制处理的时间。需要在imshow添加waitKey(30)
引用
A common mistake for opencv newcomers is to call cv::imshow() in a loop through video frames, without following up each draw with cv::waitKey(30). In this case, nothing appears on screen, because highgui is never given time to process the draw requests from cv::imshow().

来自:http://stackoverflow.com/questions/5217519/opencv-cvwaitkey
1
0
分享到:
评论
1 楼 haibuo1981 2012-02-10  
先前的描述有问题,已修正

相关推荐

Global site tag (gtag.js) - Google Analytics