1

I am trying to perform feature matching using this code from this question: OpenCV filtering ORB matches

The ORB detection works, however DescriptorExtractor and DescriptorMatcher are no longer to be found in Feature2D and any of the imports

What are their replacements in OpenCV 4 and how do I use them?

OpenCV documentation offers no help or source code unfortunately https://docs.opencv.org/4.x/d5/d51/group__features2d__main.html

Thanks,

MatOfKeyPoint keypoints = new MatOfKeyPoint();
ORB detector = ORB.create();

DescriptorExtractor descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB);;
DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);

// First photo
Imgproc.cvtColor(img1, img1, Imgproc.COLOR_RGB2GRAY);
Mat descriptors1 = new Mat();
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();

detector.detect(img1, keypoints1);
descriptor.compute(img1, keypoints1, descriptors1);

// Second photo
Imgproc.cvtColor(img2, img2, Imgproc.COLOR_RGB2GRAY);
Mat descriptors2 = new Mat();
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();

detector.detect(img2, keypoints2);
descriptor.compute(img2, keypoints2, descriptors2);

// Matching

MatOfDMatch matches = new MatOfDMatch();
MatOfDMatch filteredMatches = new MatOfDMatch();
matcher.match(descriptors1, descriptors2, matches);

List<DMatch> matchesList = matches.toList();
Mich
  • 3,188
  • 4
  • 37
  • 85
  • undeclared crosspost: https://forum.opencv.org/t/opencv-4-7-java-descriptorextractor-and-descriptormatcher-are-missing-what-do-i-use-instead-no-code-in-documenation/12332 – Christoph Rackwitz Mar 13 '23 at 07:36

1 Answers1

0

They just switched the code without updating any of the documentation, as evident by DescriptorExtractor still being present in the documentation,

answers found in opencv forums

https://answers.opencv.org/question/210523/orb-implementation-in-javaandroid-package/

        ORB detector = ORB.create();
        detector.detect(img, keypoints1, descriptors1);
        detector.detectAndCompute(img, new Mat(), keypoints1, descriptors1);

The ExtractorMatcher is still in OpenCV 4.7 however, so it can still be used

Mi Po
  • 1,123
  • 2
  • 12
  • 21
  • not just in the old forum, also in the new forum: https://forum.opencv.org/t/opencv-4-7-java-descriptorextractor-and-descriptormatcher-are-missing-what-do-i-use-instead-no-code-in-documenation/12332 – Christoph Rackwitz Mar 13 '23 at 07:36