Get function type from OpenCV FeatureDetector

In OpenCV, it is very often created cv::FeatureDetectorby providing a function name:

cv::Ptr<cv::FeatureDetector> detector = cv::FeatureDetector::create("SURF");

This is a factory template, which is an cv::FeatureDetectorabstract class.

Then, given the type variable cv::Ptr<cv::FeatureDetector>, is it possible to get the function name? This is "SURF"in my example.

+4
source share
1 answer

Classes derived from cv::Algorithminherit a method name()that returns a string containing the name of the algorithm. In the case of your SURF detector, name()returns the string

Feature2D.SURF

. , algorithm-type.instance-name, . Feature2D. , .

auto surf = cv::FeatureDetector::create("SURF");
auto n = surf->name();
std::cout << n << std::endl; // Prints "Feature2D.SURF", sans quotes
+7

Source: https://habr.com/ru/post/1537397/


All Articles