Android: How to change GRID_ORB parameters?
Hi, I can change ORB parameters but I can't change GRID_ORB parameters. I'm using GRID_ORB for feature detector in Android Studio. I'm trying to change the parameters based on this. When I change nFeatures to 60 and maxTotalKeypoints to 60 too, it still give me 500 keypoints (default). This is my code that isn't working:
File outputDir = getCacheDir();
File outputFile = null;
try {
outputFile = File.createTempFile("orbDetectorParams", ".YAML", outputDir);
writeToFile(outputFile, "%YAML:1.0\n WTA_K: 2\n edgeThreshold: 3\n firstLevel: 0\n nFeatures: 60\n nLevels: 8\n patchSize: 31\n scaleFactor: 1.2000000476837158e+00\n scoreType: 0\n gridCols: 4\n gridRows: 4\n maxTotalKeypoints: 60\n");
} catch (IOException e) {
e.printStackTrace();
}
detector.read(outputFile.getPath());
This is how I change ORB parameters:
writeToFile(outputFile, "%YAML:1.0\nscaleFactor: 1.2\nnLevels: 8\nfirstLevel: 0 \nedgeThreshold: 31\npatchSize: 31\nWTA_K: 2\nscoreType: 1\nnFeatures: 60\n");
I've tried almost everything but it's still not working. Can you help me?
just saying - be careful there, the whole idea of grid/pyramid based features was discarded in opencv3, so you won't be able to support that feature with newer opencv versions.
@berak, why was the idea discarded? It sounds valid right?
i have no idea, why it was removed (big cleanup in the features2d module, i guess)
@berak is there any way to do GRID manually with ORB? Because in my case, ORB tends to clumping around certain area.
sure you can make your own grid (just make some raster, and add a kp each 10 pixels)
but why would you want that ? your "clumping" only means, that there's something intereesting, feature-rich there, while a grid would have lots of "boring", empty spots.
what are you trying to achieve with your feature detection, anyway ?
I'm recognizing money. This is the money link. ORB tends to clump around the number on the top left, and the word on the bottom left, which look similar in every other money, so it usually gives wrong result. It's a little bit better with GRID_ORB. But for my project, I need to analize the best parameter, which I can't change in GRID_ORB.
well, though, with a grid of keypoints, you could use e.g. an SVM for the classification, instead of the feature-matchers (which will do most poorly for your problem)
but sorry, can neither help with opencv2.4, nor with android there.