Ask Your Question
1

Why am i getting this OpenCV error Assertion Failed?

asked 2013-04-17 18:24:05 -0600

Dirhem gravatar image

updated 2013-04-25 06:59:46 -0600

Here is the code :

Mat _orange = imread("orange.jpg");
Mat_<Vec3f> orange;
_orange.convertTo(orange, orange.type(), 1.0/255.0);

The _orange.convertTo(orange, orange.type(), 1.0/255.0); part causes the error.

Here is the error message:

OpenCV Error: Assertion failed (!fixedType() || ((Mat*)obj)->type() == mtype) in unknown function.

PS: I am using Visual Studio 2012 and OpenCV 2.4.4

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2013-04-18 01:56:13 -0600

berak gravatar image

believe it or not, your src img must be empty !

thow in a check before processing it:

Mat _orange = imread("orange.jpg");
if ( _orange.empty() )
{
     cerr << "foul orange!" << endl;
}
edit flag offensive delete link more
1

answered 2013-04-18 01:55:38 -0600

Basically what are you trying to do? As far as I can see you are trying to push CV_8UC3 data into a Matrix of vectors. However, I do not see why you would do that. The resulting _orange still takes the orange.type which is 3 channels.

Try changing the orange.type() into CV_8UC1, which tells you want to store vector data into a single channel matrix with vectors.

edit flag offensive delete link more

Comments

I am trying to run a sample code for pyramid blending. However i got this error in this part of code.

Dirhem gravatar imageDirhem ( 2013-04-18 05:56:29 -0600 )edit

Did you try changing the destination type? Like I suggested?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-18 13:30:10 -0600 )edit

I did but it didn't work. Now code works because i changed the source image which oddly loaded as single channel.

Dirhem gravatar imageDirhem ( 2013-04-18 15:22:44 -0600 )edit

Then please post your answer and accept it so that topic gets closed.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-21 10:15:40 -0600 )edit

Question Tools

Stats

Asked: 2013-04-17 18:24:05 -0600

Seen: 12,484 times

Last updated: Apr 25 '13