Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unhandled exceptio n with OpenCV Error: Assertion failed (!empty())....

My program is crashing with following error message:

OpenCV Error: Assertion failed (!empty()) in unknown function, file C:\Opencv-2.4.6\modules\core\src\gpumat.cpp, line 1508

When I traced it. It is referring to the second line of this function from gpumat.cpp file.

GpuMat& cv::gpu::GpuMat::setTo(Scalar s, const GpuMat& mask)
        CV_Assert(mask.empty() || mask.type() == CV_8UC1);

        gpuFuncTable()->setTo(*this, s, mask);

         return *this;

I added try-catch block around my code.

VideoCapture cap;;
if (!cap.isOpened())
    cerr << "can not open camera or video file" << endl;
    return -1;
GpuMat d_frame;
cap >> frame;
catch(cv::Exception &excep)

However, I still get the same unhandled exception. Any help is appreciated