Android: How to change GRID_ORB parameters?

asked 2016-11-03 11:25:57 -0500

gi gravatar image

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?

edit retag flag offensive close merge delete

Comments

1

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 gravatar imageberak ( 2016-11-03 11:29:47 -0500 )edit

@berak, why was the idea discarded? It sounds valid right?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-11-04 05:39:46 -0500 )edit

i have no idea, why it was removed (big cleanup in the features2d module, i guess)

berak gravatar imageberak ( 2016-11-04 05:56:25 -0500 )edit

@berak is there any way to do GRID manually with ORB? Because in my case, ORB tends to clumping around certain area.

gi gravatar imagegi ( 2016-11-04 08:08:42 -0500 )edit
1

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 ?

berak gravatar imageberak ( 2016-11-04 08:35:33 -0500 )edit

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.

gi gravatar imagegi ( 2016-11-04 09:35:53 -0500 )edit
1

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.

berak gravatar imageberak ( 2016-11-04 09:43:50 -0500 )edit