Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

For the first point, a possible solution:

std::map<std::string, cv::Ptr<cv::Feature2D> > feature;
//if-else on feature name
if(featureName == "SIFT") {
  feature[featureName] = cv::xfeatures2d::SIFT::create();
} else if(featureName == "SURF") {
  feature[featureName] = cv::xfeatures2d::SURF::create();
} //[...]

Same thing for your second point. I think that you can just recall the correct constructor on the smart pointer based on the feature name with the appropriate parameters.

As far as I know, there should be no significant downside as the feature2D class doesn't embedded important data (like a list of coordinates for example) that could be lost and would have to be copied with the call of the constructor with new parameters. Up to you to handle the different parameters (what parameter has changed) in your class.