Ask Your Question
10

How to use the LshIndexParams?

asked 2012-07-18 12:08:40 -0600

sammy gravatar image

updated 2012-07-19 01:44:20 -0600

I want to try out the new matching algorithm in flann, with LSH. But there is no info available.

What is the significance of the parameters in the LshIndexParams constructor?

LshIndexParams(int table_number, int key_size, int multi_probe_level);

Also, can you suggest some default values to start with? For a better context, I want to replace the BruteForceMatcher<Hamming> in the FREAK sample.

I would also want to know whether I should instantiate the matcher with a custom SearchParams.

Edit

I have tried to set the parameters recommended by docs (and some random combinations):

FlannBasedMatcher matcher2(new flann::LshIndexParams(20,10,2));

but it throws an error inside miniflann : cvflann::anyimpl::bad_any_cast

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
14

answered 2012-07-20 02:47:35 -0600

Maria Dimashova gravatar image

I reproduced your problem. It's a bug in the LshIndex constuctor with its members types in lines 93-95 of lsh_index.h. 'unsigned' type has to be there instead of 'int'. It works for me with this fix. But I can not put the fix to the OpenCV repo because it's read-only now. Please open an issue on OpenCV redmine when it'll be also available to be sure that I have not forgotten to fix it.

edit flag offensive delete link more

Comments

1

Thanks for all your effort, Maria! I will try to manually correct it on my machine. Btw, I appreciate your work on OpenCV!

sammy gravatar imagesammy ( 2012-07-20 04:01:16 -0600 )edit
1

@Maria: i have done your edit and now it's working correctly. I wonder how is possibile there was this huge bug. It seems no one did a simple testing after having implemented it

yes123 gravatar imageyes123 ( 2012-07-20 11:09:57 -0600 )edit
1

You are welcome to beta-test the next version of OpenCV! You could work on some unit-tests for the library as well.

Kirill Kornyakov gravatar imageKirill Kornyakov ( 2012-07-22 03:17:55 -0600 )edit
3

@sammy Thank you for your kind words!

@yes123 I suppose it's Flann bug that came to OpenCV. I was curious and checked the last Flann 1.7.1 today. It's OK in that place now. OpenCV definitely has to improve Flann testing. Some simple tests were added ~2 years ago and there was not LSH index in used version of Flann at that date.

Our effort is often not enough to make OpenCV ideal library :) You, OpenCV users, help us by your bug reports and fixing patches. But you can help us even more. Please, write tests for uncovered OpenCV functionality! (Here I repeat with Kirill). And we'll run and check them every day as we do with existing tests set now.

Maria Dimashova gravatar imageMaria Dimashova ( 2012-07-22 03:32:44 -0600 )edit
3

Fixed in the master 54d68da8.

Maria Dimashova gravatar imageMaria Dimashova ( 2012-07-24 13:15:30 -0600 )edit

I am using OpenCV 2.4.7 but it still throw 'cvflann::anyimpl::bad_any_cast'.. Anyone know what is wrong? thx

Ben Lau gravatar imageBen Lau ( 2013-11-28 19:16:00 -0600 )edit

ohoho , I found out the reason. It is the problem of source installation of OpenCV. There has multiple version on my Linux and it is linked to old version. It is fixed. thx

Ben Lau gravatar imageBen Lau ( 2013-11-29 11:03:58 -0600 )edit
1

answered 2012-07-18 19:33:32 -0600

Vincent Rabaud gravatar image

Those parameters are the ones of the LSH multi-probe algorithm but its implementation is only for binary features right now. I'll add that to the docs. What is the type of the FREAK features ? (floats ? binary ?).

My guess is that the cast error you get is because the type is not binary.

edit flag offensive delete link more

Comments

1

The docs and the FREAK code example say that the descriptors are binary: FREAK: A cascade of binary strings is computed .... Also, the demo matcher uses BruteForce<Hamming>, which is a binary matcher.

sammy gravatar imagesammy ( 2012-07-19 01:36:18 -0600 )edit

Question Tools

5 followers

Stats

Asked: 2012-07-18 12:08:40 -0600

Seen: 22,626 times

Last updated: Jul 20 '12