Ask Your Question
0

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

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

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);
        CV_DbgAssert(!empty());

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

         return *this;
    }

I added try-catch block around my code.

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

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

edit retag flag offensive close merge delete

Comments

Thanks @StevenS, It worked.

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

1 answer

Sort by ยป oldest newest most voted
1

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

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
Login/Signup to Answer

Question Tools

Stats

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

Seen: 446 times

Last updated: Jun 04 '14