It seems you would like the feature provided by the Ptr<FeatureDetector> cv::FeatureDetector::create(const string& detectorType)
function:
"FAST" – FastFeatureDetector
"STAR" – StarFeatureDetector
"SIFT" – SIFT (nonfree module)
"SURF" – SURF (nonfree module)
"ORB" – ORB
"BRISK" – BRISK
"MSER" – MSER
"GFTT" – GoodFeaturesToTrackDetector
"HARRIS" – GoodFeaturesToTrackDetector with Harris detector enabled
"Dense" – DenseFeatureDetector
"SimpleBlob" – SimpleBlobDetector
Also a combined format is supported:
feature detector adapter name ( "Grid" – GridAdaptedFeatureDetector, "Pyramid" – PyramidAdaptedFeatureDetector )
+ feature detector name (see above), for example: "GridFAST", "PyramidSTAR"
It returns a pointer to the FeatureDetector base class, so you can use polymorphism to select specific implementation at runtime:
//assuming image path is the first command line parameter and detector type is the second parameter
auto image = cv::imread(argv[1]);
auto ptr = cv::FeatureDetector::create(argv[2]); //auto evaulates to cv::Ptr<cv::FeatureDetector> here
std::vector<cv::KeyPoint> keypoints;
ptr->detect(image, keypoints);
for (auto kp : keypoints)
cv::circle(image, kp.pt, 2, cv::Scalar(0, 255, 255), -1);
cv::imwrite(argv[1], image);