2

The FLANN matcher in OpenCV C++ works fine, but from looking around it seems that there is no wrapper for FlannBasedMatcher in OpenCV Java, but I have found two possible(?) workarounds which I am not quite sure how to use.

The first is an answer to a previous question:

http://answers.opencv.org/question/12429/matching-orb-descriptors-with-flann-lsh-on-android/?answer=12460#post-id-12460

But I'm not quite sure what he means by "creating a Matcher using common matcher factory and setting parameters"

Another option is using JavaCV which seems to have an implementation of flann:

https://github.com/bytedeco/javacpp-presets/blob/master/opencv/src/main/java/org/bytedeco/javacpp/opencv_flann.java

I've been developing an app on android using the original OpenCV Java libraries but I'm wondering, is it possible to use JavaCV alongside, so that I can use the JavaCV's FLANN functions, or will using both libraries at the same time not work? Or does anyone know how to use the first answers suggestion?

Any help would be greatly appreciated, thanks.

Valckrie
  • 23
  • 1
  • 5
  • I've used both in same code before. It gets confusing when you're mixing opencv java bindings and JavaCV. You might have some naming conflicts so you have to use fully qualified package names, and it adds complexity, but it worked when I tried it a couple years ago when JavaCV had implemented some face detection stuff not available in opencv yet. Sorry, can't help with Flann. – medloh Nov 04 '15 at 23:01

2 Answers2

2
  1. For the first method, "creating a Matcher using common matcher factory and setting parameters" means the following code

DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.FLANNBASED);

For setting parameters in Java, you will have to create a yaml config file and the use matcher.read() to read the parameters as there is currently no wrapper for config parameters in Java. Another thing to note is

  1. As for using JavaCV, medloh's comment is correct. It adds complexity but is possible.
Him
  • 1,609
  • 12
  • 20
0

There was a bug in OpenCV java wrapping prior to version 3.2. The recent version does not have this defect so you can instantiate FLANN matcher in Java as follows:

FlannBasedMatcher matcher = FlannBasedMatcher.create();

DescriptorMatcher is the obsolete wrapper, I would not recommend using it.

Alex B
  • 70
  • 7