OpenCV 4.7 Java DescriptorExtractor and DescriptorMatcher are missing, what do I use instead, no code in documenation

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 OpenCV: Feature Detection and Description


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();

undeclared crosspost:

first, I’d recommend SIFT and AKAZE over ORB.

just instantiate the thing you want directly, using its create() method.

matchers… use FLANN. also create().

Looks like OpenCV changed the format of the class without updating the documentation.

The documentation is also pretty pathetic, as it offers nothing more than class and function descriptors that you get by searching the header files. No source code, no example usages, etc

Here is the fix below:
Sadly I had to find this by searching Stack Overflow and not the official OpenCV resources.

        detector.detect(img, keypoints1, new Mat());
        switch_image = false;
        detector.detectAndCompute(img, new Mat(), keypoints1, descriptors1);