Ask Your Question

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

asked 2014-06-04 05:34:44 -0600

Tariq gravatar image

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

edit retag flag offensive close merge delete


Thanks @StevenS, It worked.

Tariq gravatar imageTariq ( 2014-06-04 09:17:40 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-06-04 16:18:35 -0600

Try initianating your GpuMat as follows and skip the upload function. GpuMat d_frame (frame); It should fix the problem, if not, your frame is up higher and your original frame is empty.

Since you commented that it worked, do accept this answer :)

edit flag offensive delete link more

Question Tools


Asked: 2014-06-04 05:34:44 -0600

Seen: 785 times

Last updated: Jun 04 '14