Send parameters to ORB Feature Detector, Android

asked 2015-11-11 16:57:06 -0500

Bob W gravatar image

I need to send parameters to the ORB Feature Detector from my Android app. The workaround mentioned here no longer seems to work. I am using OpenCV 3.0.

If I try to set parameters by writing a temp file, they seem to be ignored. If I deliberately mis-type a parameter name, it doesn't do anything. If I write out the parameters using the write() method, a file is indeed created but all it has is a 1-line header "%YAML: 1.0". XML fails too.

// try setting some params.
// first write a file (this is indeed created and can be viewed with 'adb shell')
String tempFileName = writeToFile("tempFile", "%YAML:1.0\nscaleFactor: 1.1\nnLevels: 5\nfirstLevel: 0\nedgeThreshold: 31\npatchSize: 31\n");;  // seems to have no effect.

// try writing out params.
String fileName = myDir.getPath() + "/orb_params.yml";
_detector.write(fileName);  // try yaml
fileName = myDir.getPath() + "/orb_params.xml";
_detector.write(fileName);  // try xml
edit retag flag offensive close merge delete


In the new OpenCV 3 API each feature detector has its own set of getters and setters to configure the parameters as seen here. However it seems that the Java build does not contain those ... maybe @berak can shed a light on this?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-11-12 05:13:03 -0500 )edit
  • the features2d java wrappers are some special hack (features2d/misc/java) and still follow the outdated 2.4 programming model
  • ORB just does not save or read any params (no matter if c++,java,xml,yml) , others like SimpleBlobDetector, KAZE / AKAZE do.

no real idea, what to do here. i'm a bit afraid, this is one of those "wontfix" things. it needs a radical change there, imho, and so far noone has made an attempt to do so (would break current java api, etc.)

berak gravatar imageberak ( 2015-11-12 05:40:16 -0500 )edit

Thanks for your feedback. So if I understand correctly, read/write is the only way to set/get params in Java but read/write is not implemented in ORB in C++. However it is implemented for other feature detectors in C++ so read/write will work with them from Java. Do I have that right?

Bob W gravatar imageBob W ( 2015-11-12 21:57:03 -0500 )edit

^^ yes. that's right

berak gravatar imageberak ( 2015-11-12 23:54:57 -0500 )edit

Is this still a issue, or did you manage to find a workaround?

ChristianLJ gravatar imageChristianLJ ( 2015-11-28 07:56:32 -0500 )edit