3

Is it normal? When I tried the brute force matcher, the result is consistent everytime, but flann is not. A small amount of keypoints will match to different places. I am writing the code using the Android wrapper, the keypoint detector and descriptor is SURF, something like this:

Mat queryDescriptors = new Mat();
Mat trainDescriptors = new Mat();
DescriptorExtractor surfDE = DescriptorExtractor.create(DescriptorExtractor.SURF);
surfDE.compute(queryImage, queryKeyPoints, queryDescriptors);
surfDE.compute(trainImage, trainKeyPoints, trainDescriptors);
DescriptorMatcher dm = DescriptorMatcher.create(DescriptorMatcher.FLANNBASED);
List<DMatch> matches = new ArrayList<DMatch>();
dm.match(queryDescriptors, trainDescriptors, matches);
kaitik
  • 224
  • 4
  • 10

2 Answers2

5

FLANN stands for Fast Library for Approximate Nearest Neighbors. The approximate nearest neighbor algorithms are non-deterministic, often randomized KD-trees.

  • You can fix seed with `cv::setRNGSeed(2391);` before each FLANN usage. Note that this will not reliably work if you use FLANN from multiple threads at the same time. – Polar Nick Sep 02 '22 at 18:41
2

According to Andrey, this is the reason! So yes, it is normal. To find more one would have to dissect the algorithms!

MobileCushion
  • 7,065
  • 7
  • 42
  • 62