1 | initial version |
your image wasn't valid, and imshow() does not like it at all.
you should check the return value of VideoCapture::read(), like :
bool ok = stream1.read(cameraFrame);
if (! ok)
continue;
some older webcam models need a "warmup", and might return empty Mat's initially.
2 | No.2 Revision |
your image wasn't valid, and imshow() does not like it at all.
you should check the return value of VideoCapture::read(), like :
bool ok = stream1.read(cameraFrame);
if (! ok)
continue;
some older webcam models need a "warmup", and might return empty Mat's initially.
also it should rather be:
if (!stream1.isOpened()) { //check if video device has been initialised
cout << "cannot open camera" << endl;
return -1;
}
(flush the stream, and return on error. maybe you only missed the msg, because it borked, before it could get printed)