I'm using OpenCV 2.2 on Visual C++ 2010 Express on Windows 7 64 bit. Whenever I try running some simple program to access and display the images from the webcam, I get a black output window instead of the actual webcam feed. OpenCV detects a webcam, doesn't report any errors or warnings, but each frame is a blacked out image.
This is the code I've been trying on:
#include <opencv2/opencv.hpp>
using namespace cv;
int main()
{
Mat img;
VideoCapture cap(0);
while (true)
{
cap >> img;
Mat edges;
cvtColor(img, edges, CV_BGR2GRAY);
Canny(edges, edges, 30, 60);
imshow("window label", img);
waitKey(100);
}
return 0;
}
Any idea on what seems to be the problem? Everything was working fine on OpenCV 2.4.2, but I had to switch since I could not get MSER to work properly.