OpenCV2.2,vs2010,win7
程序读一段视频,然后进行分析处理,在显示视频的时候,却发现imshow无法显示读取的帧。代码如下:
跟踪了一下,发现确实是读入了帧,只是在显示的时候没有出来。
在网上查了下文档,原来是循环中,highgui没有给予imshow绘制处理的时间。需要在imshow添加waitKey(30)
转自: http://haibuo1981.iteye.com/blog/1401764
程序读一段视频,然后进行分析处理,在显示视频的时候,却发现imshow无法显示读取的帧。代码如下:
- VideoCapture cap;
- cap.open("test.avi");
- namedWindow("video",1);
- for(;;){
- Mat frame;
- cap<<frame;
- if(frame.empty())
- break;
- imshow("video",frame);
- //waitKey(30)
- }
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://haibuo1981.iteye.com/blog/1401764




2227

被折叠的 条评论
为什么被折叠?



