我正在尝试使用以下问题中的代码执行特征匹配:OpenCV filtering ORB matches
ORB检测有效,但在Feature2D和任何导入中均找不到描述符提取器和描述符匹配器
OpenCV 4中有哪些替代品?如何使用它们?
OpenCV文档没有提供任何帮助或源代码,很遗憾https://docs.opencv.org/4.x/d5/d51/group__features2d__main.html
谢谢你,
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();
1条答案
按热度按时间xnifntxz1#
他们只是切换了代码,而没有更新任何文档,这从文档中仍然存在的DescriptorExtractor可以看出,
在opencv论坛中找到的答案
https://answers.opencv.org/question/210523/orb-implementation-in-javaandroid-package/
不过,ExtractorMatcher仍在OpenCV 4.7中,因此仍然可以使用