Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to limit number of keypoints in DogSIFTEngine? #304

Open
barryspearce opened this issue Mar 22, 2021 · 1 comment
Open

How to limit number of keypoints in DogSIFTEngine? #304

barryspearce opened this issue Mar 22, 2021 · 1 comment

Comments

@barryspearce
Copy link

barryspearce commented Mar 22, 2021

Is it possible to limit the keypoints to the best n keypoints?

A 1000px max long side image produces 29823 keypoints. Then going into the RobustAffineTransformEstimator to check for geometric an exception is thrown:

Exception in thread "main" java.lang.IllegalArgumentException: Matrix of 59646 x 59646 = 3557645316 elements is too large to be allocated using a single Java array.
at no.uib.cipr.matrix.AbstractDenseMatrix.(AbstractDenseMatrix.java:53)
at no.uib.cipr.matrix.DenseMatrix.(DenseMatrix.java:167)
at no.uib.cipr.matrix.SVD.(SVD.java:97)
at no.uib.cipr.matrix.SVD.(SVD.java:75)
at no.uib.cipr.matrix.SVD.factorize(SVD.java:149)
at org.openimaj.math.matrix.MatrixUtils.solveHomogeneousSystem(MatrixUtils.java:1549)
at org.openimaj.math.matrix.MatrixUtils.solveHomogeneousSystem(MatrixUtils.java:1522)
at org.openimaj.math.geometry.transforms.TransformUtilities.affineMatrix(TransformUtilities.java:478)
at org.openimaj.math.geometry.transforms.AffineTransformModel.estimate(AffineTransformModel.java:104)
at org.openimaj.math.model.fit.RANSAC.fitData(RANSAC.java:529)
at org.openimaj.math.geometry.transforms.estimation.RobustAffineTransformEstimator.fitData(RobustAffineTransformEstimator.java:134)
at org.openimaj.feature.local.matcher.consistent.ConsistentLocalFeatureMatcher2d.findMatches(ConsistentLocalFeatureMatcher2d.java:138)
at imgtest.ImgTest.featureMatch(ImgTest.java:111)
at imgtest.ImgTest.main(ImgTest.java:54)

I am trying to re-produce SIFT searches originally written using OpenCV (in java) but I would like to use OpenIMAJ instead for better portability. OpenCV allows a limit on keypoint detectors so that only the best n are returned. Typically for my purposes I have found that around 2000 of the best keypoints are all that is needed to produce highly accurate matches with low numbers of false negatives, and exceedingly low false positives. Being able to limit this also increases performance as subsequent matching doesn't need to be based on such a large set - and of course the exception is avoided.

Is there a way to control keypoint selection?

@jonhare
Copy link
Member

jonhare commented Mar 22, 2021

I'm sort of surprised that your finding so many keypoints on a 1000px image - the default settings follow Lowe's original paper & should normally just give you a few thousand points.... That being said, you have full control over the keypoints being detected by passing in a DoGSIFTEngineOptions object to the DoGSIFTEngine constructor (or call getOptions() on the instance you already have). Try playing with setEigenvalueRatio() and setMagnitudeThreshold() to reduce the number of keypoints found (in both cases raising it will reduce the number I think). Potentially options.setDoubleInitialImage(false) might also give you a quick fix and also make everything faster, but it might affect matching performance too much --- really depends on the types of images for your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants