Ask Your Question
0

GenericDescriptorMatcher for Fern algorithm

asked 2013-04-02 05:48:15 -0500

fuego gravatar image

Hi everyone,

I'm french so sorry for my english. I try to implement the Fern algorithm with the GenericDescriptorMatcher but i have a problem.

I'm using many pictures in order to match the test image with this database. However when i launch the method "classify" (of GenericDescriptorMatcher)

"ps_descriptorMatcher->classify(s_testImage, s_testKeypoints);"

i have this error:

OpenCV Error: Assertion failed (imgIdx < (int)images.size()) in getKeyPoint, file /build/buildd/opencv-2.3.1/modules/features2d/src/matchers.cpp, line 918 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.3.1/modules/features2d/src/matchers.cpp:918: error: (-215) imgIdx < (int)images.size() in function getKeyPoint

I don't understand why the idx is bigger than the image?

Can you help me please ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-04-02 05:50:05 -0500

Note that images.size() does not refer to a single image, but to a container of images, giving you the amount of images in it.

Provide us with more code, you must be doing something wrong before that line by instantiating your objects.

edit flag offensive delete link more

Comments

Thank you for your interest.

It's a summary of my code:

vector<cv::Mat> images; vector< vector<cv::KeyPoint> > keypoints;

descriptorMatcher = cv::GenericDescriptorMatcher::create("FERN", filename); descriptorMatcher->add(images, keypoints); descriptorMatcher->train();

cv::Mat testImage = cv::imread("test.jpg"); vector<cv::KeyPoint> testKeypoints;

descriptorMatcher->classify(testImage, testKeypoints);"

The keypoints are found with SURF detection.

In the "classify" method, it will have to be the query image, right? So why there are an error with this variable (images) ?

fuego gravatar imagefuego ( 2013-04-02 07:58:18 -0500 )edit

I have not enough experience with this code, but what i find weird is you training a matcher with a vector of keypoint vectors. Could it be that the inner vector should be a Mat element with features detected on a row element?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-02 10:19:08 -0500 )edit
1

@fuego: Interesting, haven't used Fern so far either (maybe because they are under legacy). I guess you just abbreviated your code but for being sure: The vector of images contains your images and the vector of keypoints contains the computed keypoints for these images? Because the error may mean that your keypoints don't fit to your images (the same may be for you call to 'classify': Does the keypoints belong to this image?)

To answer your question in your comment: yes, according to the documentation you should pass the query image for 'classify'.

Guanta gravatar imageGuanta ( 2013-04-02 17:38:15 -0500 )edit
1

@steven: I don't think that you give features to the 'fern'-classifier, according to http://www.computer.org/csdl/trans/tp/2010/03/ttp2010030448.pdf which is referenced in modules/legacy/src/planardetect.cpp it classifies the patches surrounding the keypoints which you need to pass to the Fern-classifier.

Guanta gravatar imageGuanta ( 2013-04-02 17:39:39 -0500 )edit

Quanta : Exactly, the images are the train images with their respective keypoints (for each one). And "testKeypoints" are the computed keypoints of "testImage". I have checked that the keypoints are not out of the images.

So i don't know why this error appears.

Adding more precision to my application, i try to find an object in a panorama. However the panorama it is not just one image but many tiles. Consequently, my test image is not exactly the same of a tile but it looks like one of them.

fuego gravatar imagefuego ( 2013-04-03 02:50:46 -0500 )edit

Any others suggestions?

fuego gravatar imagefuego ( 2013-04-04 05:37:29 -0500 )edit

Sry, currently not, however I am very curious about it myself. Maybe you want to post the question to stackoverflow? Maybe I'll also have the time to try it out myself during the next week, but I cannot promise it - much to do :(

Guanta gravatar imageGuanta ( 2013-04-06 08:04:51 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-04-02 05:48:15 -0500

Seen: 1,046 times

Last updated: Apr 02 '13