Assertion failed (size.width>0 && size.height>0)

前端 未结 3 1778
灰色年华
灰色年华 2020-11-30 13:27

I\'m using Visual Studio Express 2013 with OpenCV 2.4.7, following this tutorial.

I have spent hours searching the web for solutions, including all of t

3条回答
  •  旧巷少年郎
    2020-11-30 14:11

    I tried your code and for me it works (it visualizes the current webcam input)!
    I ran it on Visual Studio 2012 Ultimate with OpenCV 2.4.7.
    ...
    The error occurs because the image is empty, so try this:

    while (true) {
        cap >> image;
    
        if(!image.empty()){
            imshow("window", image);
        }
    
    // delay 33ms
    waitKey(33);        
    }
    

    Maybe the first image you receive from your webcam is empty. In this case imshow will not throw an error. So hopefully the next input images are not empty.

提交回复
热议问题