Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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:

image description

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 ! :)

click to hide/show revision 2
None

updated 2018-04-26 01:00:32 -0600

berak gravatar image

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:

image description

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 ! :)

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 ! :)

click to hide/show revision 4
None

updated 2018-04-26 03:27:11 -0600

berak gravatar image

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

int main() {
    VideoCapture stream1(0);

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;}`
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 ! :)

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 ! :)

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 ! :)