Ask Your Question
10

How to use the LshIndexParams?

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

sammy gravatar image sammy
2550 10 20 41

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

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

delete close flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
11

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

Maria Dimashova gravatar image Maria Dimashova
1060 4 12 26

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.

link delete flag offensive edit

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 ( 2012-07-20 04:01:16 -0500 )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 ( 2012-07-20 11:09:57 -0500 )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 ( 2012-07-22 03:17:55 -0500 )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 ( 2012-07-22 03:32:44 -0500 )edit
3

Fixed in the master 54d68da8.

Maria Dimashova ( 2012-07-24 13:15:30 -0500 )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 ( 2013-11-28 19:16:00 -0500 )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 ( 2013-11-29 11:03:58 -0500 )edit
0

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

Vincent Rabaud gravatar image Vincent Rabaud
216 1 7

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.

link delete flag offensive edit

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 ( 2012-07-19 01:36:18 -0500 )edit

Login/Signup to Answer

Question tools

Follow
4 followers

subscribe to rss feed

Stats

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

Seen: 7,757 times

Last updated: Jul 20 '12