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

前端 未结 3 1780
灰色年华
灰色年华 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

    Do this:

    VideoCapture cap;
    cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
    cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
    int camOpen = cap.open(CV_CAP_ANY);
    

    Or you can try changing this:

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

    to

    try
    {
         cap >> image;
         imshow("window", image);
         waitKey(33); 
    }
    catch (Exception& e)
    {
        const char* err_msg = e.what();
        std::cout << "exception caught: imshow:\n" << err_msg << std::endl;
    }
    

提交回复
热议问题