Ask Your Question
1

Why am i getting this OpenCV error Assertion Failed?

asked Apr 18 '13

Dirhem gravatar image

updated Apr 25 '13

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

Preview: (hide)

2 answers

Sort by » oldest newest most voted
2

answered Apr 18 '13

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;
}
Preview: (hide)
1

answered Apr 18 '13

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.

Preview: (hide)

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 (Apr 18 '13)edit

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

StevenPuttemans gravatar imageStevenPuttemans (Apr 18 '13)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 (Apr 18 '13)edit

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

StevenPuttemans gravatar imageStevenPuttemans (Apr 21 '13)edit

Question Tools

Stats

Asked: Apr 18 '13

Seen: 12,572 times

Last updated: Apr 25 '13