How should I replace FeatureDetector function in new OpenCV?

醉酒当歌 提交于 2019-11-29 11:59:54

You can continue with this and this will work. Deprecation means that there is new recommended alternative, but off course old code will still work. The new way of doing that would be using FastFeatureDetector or AgastFeatureDetector depending on your use case. I am not familiar with OpenCV so unfortunately I can't recommend which exact implementation you need, you need to read JavaDoc/other docs and find out which would fit your code.

By reading this documentation page , it is obvious that now we instantiate directly the required detector, such as:

Mat mask = new Mat();
MatOfKeyPoint keypoints = new MatOfKeyPoint();
MSER detector = MSER.create();
detector.detect(imageMat, keypoints, mask);

It is excatly the same for ORB, just change the class:

Mat mask = new Mat();
MatOfKeyPoint keypoints = new MatOfKeyPoint();
ORB detector = ORB.create();
detector.detect(imageMat, keypoints, mask);

Before deprecation we had to write something similar to (this is the OLD class ):

FeatureDetector _featureDetector = FeatureDetector.create(FeatureDetector.ORB);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!