Ask Your Question

Revision history [back]

click to hide/show revision 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.

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)