In OpenCV, it is very common to create a cv::FeatureDetector
by providing the name of the feature:
cv::Ptr<cv::FeatureDetector> detector = cv::FeatureDetector::create("SURF");
This is a factory pattern, being cv::FeatureDetector
an abstract class.
Then, given a variable of type cv::Ptr<cv::FeatureDetector>
, is it possible to retrieve the name of the feature? It is "SURF"
in my example.
Classes derived from cv::Algorithm
inherit a name()
method which returns a string containing the algorithm name. In the case of your SURF detector, name()
returns the string
Feature2D.SURF
which is a human-readable form. In general, this string is of the form algorithm-type.instance-name, though a very few just have a single-word description. For any of the feature detection algorithms, the algorithm-type prefix is always Feature2D
. You can parse it yourself if you need an exact string match.
auto surf = cv::FeatureDetector::create("SURF");
auto n = surf->name();
std::cout << n << std::endl; // Prints "Feature2D.SURF", sans quotes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With