Ask Your Question

ORB assertion failed with OpenCV 3.0.0 [closed]

asked 2017-01-19 08:07:51 -0500

ptemple gravatar image

updated 2017-01-19 10:24:37 -0500

Hi there, I'm trying to use ORB points of interest to try to retrieve an object into an image (compute points of interest; then associated descriptors and finally try to see if we can pair them and retrieve a transformation).

Here is a part of the code I use :

Ptr<cv::ORB> descriptor_ORB;
descriptor_ORB = cv::ORB::create(/*some values from a configuration file with atoi() and atof() to format values*/);

Mat model = imread(filename); //string filename -> the name of an image file
std::vector<KeyPoint> keypoints_model;
cout << "size model : " << model.cols << "\t" << models.rows << endl; //display 123 and 62 -> successfully load
Mat gray_model = model;
cvtColor(gray_model, gray_model, COLOR_BGR2GRAY); // convert to grayscale as in examples
descriptor_ORB -> detect (gray_model, keypoints_model); // compute ORB points of interest on grayscale image and put the points in the keypoints_model vector

This last line gives me an assertion failure :

OpenCV Error : Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x +roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file Matrix.cpp, line 499

Is it normal ? It is likely that the detect function is unable to retrieve any points of interest...

To avoid early, termination I put the detect call in a try/catch statement.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by ptemple
close date 2017-01-20 09:12:37.777767


You have to create descriptor :

Ptr<cv::ORB> descriptor_ORB=ORB::create();

PS Please use icon 101010 to format your code

LBerger gravatar imageLBerger ( 2017-01-19 08:23:10 -0500 )edit

Yes, sorry, I forgot this line; I edited the post, I use some values from a configuration file to create the structure.

ptemple gravatar imageptemple ( 2017-01-19 10:26:43 -0500 )edit

There is no problem with your program even with a flat image. Update to 3.2?

LBerger gravatar imageLBerger ( 2017-01-19 11:12:20 -0500 )edit

Why do I get the assertion then ? Are there any requirements on the value given to the ORB::create() function (like min/max boundary values) that would trigger the assertion ?

ptemple gravatar imageptemple ( 2017-01-19 11:20:54 -0500 )edit

I tried your program with my first comment and an image size 123 cols and 62 rows. There is no exception. When I wrote this sample in opencv 3.0. No error canyou try this sample using this image ?

LBerger gravatar imageLBerger ( 2017-01-19 11:38:51 -0500 )edit

When using your code your image given twice (for both arguments); the execution reveals some assertion failure for different descriptors : for AKAZE-DESCRIPTOR_KAZE_UPRIGHT and the hamming distance; your usage of ORB seems ok though; my configuration given by ORB::create() is as follows :

b = ORB::create(400,0,8,31,0,2,0,31,20);

the last 0 should be an index to something but I don't know which are available so... and my configuration leverage some assertion failure

OpenCV error : Assertion failed (s >= 0) in setSize, matrix.cpp, line 297
ptemple gravatar imageptemple ( 2017-01-20 04:41:23 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-01-20 09:12:16 -0500

ptemple gravatar image

In b = ORB::create(400,0,8,31,0,2,0,31,20);

the second argument should be a float greater or equals to 1 according to the documentation at (

while I set it to 0

edit flag offensive delete link more


Sorry not enough time to help you but you solve it alone :D

LBerger gravatar imageLBerger ( 2017-01-20 09:30:37 -0500 )edit

Could you add a check in the code with a more relevant message then please ?

ptemple gravatar imageptemple ( 2017-01-20 09:49:22 -0500 )edit

where do you want a relevant message

LBerger gravatar imageLBerger ( 2017-01-20 10:06:02 -0500 )edit

In the code of OpenCV; in the function detect or create for instance

ptemple gravatar imageptemple ( 2017-01-20 10:08:07 -0500 )edit

Question Tools

1 follower


Asked: 2017-01-19 08:07:51 -0500

Seen: 589 times

Last updated: Jan 19 '17