Error: Assertion failed (size.width>0 && size.height>0) in imshow
Hi all,
Just installed OpenCV yesterday and I'm trying to play around with it, to eventually work on some fun projects. At the moment I'm struggling to visualize my laptop webcam, and I can't figure out why. This is the code I'm running:
int main() {
VideoCapture stream1(0);
if (!stream1.isOpened()) { //check if video device has been initialised
cout << "cannot open camera";
}
//unconditional loop
while (true) {
Mat cameraFrame;
stream1.read(cameraFrame);
imshow("cam", cameraFrame);
exit(0);
if (waitKey(30) >= 0)
break;
}
return 0;
}
After building the project and running it, this is the error that comes up:
OpenCV(3.4.1) Error: Assertion failed (size.width>0 && size.height>0) in imshow
Thanks in advance for your help ! :)
thanks for the edit !