OpenCV的imshow无法正常显示图片

来源:互联网 发布:115浏览器 mac 编辑:程序博客网 时间:2024/04/28 08:57
写opencv的时候,遇到了使用imshow显示灰色窗口的麻烦,图像读取完全正常,但是窗口显示的只有灰色,好像哪里出错了感觉。跟踪了一下,发现确实是读入了帧,只是在显示的时候没有出来。 
在网上查了下文档,原来是循环中,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(). 
0 0