OpenCV的摄像头捕捉问题 [英] OpenCV webcam capture problem
本文介绍了OpenCV的摄像头捕捉问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经安装了OpenCV的2.2,现在我不能让摄像头捕捉工作。它在2.1的工作确定。 OpenCV中检测到的摄像头,并没有报告任何错误或警告,但每架都是灰度图像。我甚至尝试从OpenCV的维基一个code样品:</ P>
I've installed OpenCV 2.2 and now I can't get webcam capture to work. It worked ok in 2.1. OpenCV detects a webcam, doesn't report any errors or warnings, but each frame is a gray image. I even tried a code sample from OpenCV wiki:
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat edges;
namedWindow("edges",1);
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
cvtColor(frame, edges, CV_BGR2GRAY);
//GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
//Canny(edges, edges, 0, 30, 3);
imshow("edges", edges);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
有没有人遇到这个问题?我使用的是64位的Win7和Visual Studio 2010。
Did anyone run into this issue? I'm using 64bit Win7 and Visual Studio 2010.
推荐答案
我发现了一个很长的搜索后的溶液。
I found the solution after a very long search.
的问题是,如果不具有表示帧发生此问题之间的延迟。
The problem is that if doesn't have a delay between showing the frames happen this problem.
该解决方案把 cvWaitKey(20);
中环
这篇关于OpenCV的摄像头捕捉问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文