OpenCV and MJPEG USB Webcam
Hello,
I have an Imagingsource DFK AFU050-L34 USB Webcam and I wan´t use OpenCV to read out this Camera. My Code looks like this:
while(true)
{
Mat frame
VideoCapture cap;
cap.open(0);
if (!cap.isOpened())
{
cout << "Cannot open the video cam" << endl;
return -1;
}
cap.set(CV_CAP_PROP_FOURCC, CV_FOURCC('M', 'J', 'P', 'G'));
cap.set(CV_CAP_PROP_FRAME_WIDTH, 1280.0);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 720.0);
cap.set(CV_CAP_PROP_FPS, 30.0);
bool bSuccess = cap.read(frame);
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read a frame from video stream" << endl;
break;
}
imshow("MyVideo", frame);
waitKey(100);
}
After starting this programm, I´ve got a black image and my Mat Frame has a size of 1280x720. I use OpenCV 3.1 with Visual Studio 2013 on a windows 7 machine.
How can I fix this black image? Thanks for help!
Try a loop
also, please do not create the VideoCapture inside the loop
also, please do not create / open the VideoCapture inside the loop