Fig*_*aro 9 c c++ webcam opencv
我已经安装了OpenCV 2.2,现在我无法使网络摄像头捕获工作.它在2.1中运行正常.OpenCV检测到网络摄像头,不报告任何错误或警告,但每个帧都是灰色图像.我甚至尝试过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;
Run Code Online (Sandbox Code Playgroud)
有人遇到过这个问题吗?我使用的是64位Win7和Visual Studio 2010.
小智 1
我真的对 OpenCV 一无所知,但是问题不是在下面一行吗?
cvtColor(frame, edges, CV_BGR2GRAY);
Run Code Online (Sandbox Code Playgroud)
似乎您有意将 BGR 颜色空间转换为灰度空间。
不应该是这样的吗:
cvtColor(frame, edges, CV_BGR2RGB);
Run Code Online (Sandbox Code Playgroud)