0

Whats the difference between SiftFeatureDetector() and Ptr. They both apparently have the same function. The opencv tutorial uses SiftFeatureDetector but when clicking on the official documentation they use Ptr and have no mention of SiftFeatureDetector(), so I cant read up on it. as in the tutorial they used this: int minHessian = 400; SurfFeatureDetector detector( minHessian ); and I dont know what the minHessian is supposed to do.

Also I tried them both on the same image and they both have the same result, then why are they different?

int _tmain(int argc, _TCHAR* argv[])
{
//initModule_nonfree();
Mat img;

img = imread("c:\\box.png", 0);

//cvtColor( img, gry, CV_BGR2GRAY );

 //SiftFeatureDetector detector;
//vector<KeyPoint> keypoints;
//detector.detect(img, keypoints);

Ptr<FeatureDetector> feature_detector = FeatureDetector::create("SIFT");
vector<KeyPoint> keypoints;

feature_detector->detect(img, keypoints);

Mat output;

drawKeypoints(img, keypoints, output, Scalar::all(-1));

namedWindow("meh", CV_WINDOW_AUTOSIZE);
imshow("meh", output);
waitKey(0);



return 0;

}

Thank you

StuckInPhDNoMore
  • 2,507
  • 4
  • 41
  • 73
  • 1
    FeatureDector is an interface (abstract class), SiftFeatureDetector is a concrete subclass of FeatureDetector. Ptr is a [smart pointer](http://en.wikipedia.org/wiki/Smart_pointer) to an instance of class T, to ensure it is properly deleted – remi Nov 04 '12 at 17:55

1 Answers1

2

EDIT: See the correction by @gantzer89 in the comments below. (Leaving my original text in place for historical clarity.)


In my general experience, using the FeatureDetector::create() syntax (discussed here in the "official documentation" you cited) allows the flexibility to specify your algorithm at runtime via a parameter file, while the more specific classes, such as SiftFeatureDetector, provide more opportunities for customization.

The create() methods start with a set of default algorith-specific parameters, while the algorithim-specific classes allow customization of these parameters upon construction. Thus, the create() method is assigning a default value to minHessian, while the SiftFeatureDetector constructor provides the opportunity to choose a value of minHessian.

As a rule of thumb, if you want to quickly experiment with which algorithm to use, use the create() syntax, and if you want to experiment with fine-tuning a particular algorithm, use the algorithm-specific class constructor.

arr_sea
  • 841
  • 10
  • 16
  • 2
    This is not true, using FeatureDetector::create for detector instantiation allows as well tuning parameters since detector is also a cv::Algorithm and hence its parameters might be changed using cv::Algorithm::set. And if the available parameters are not known they can be easily retrieved looking at the output of cv::Algorithm::getParams – Andres Felipe Aug 19 '13 at 16:35
  • can I set the minHessian somehow (for the `create()`) ? –  May 08 '17 at 00:50