SiftFeatureDetector() 和 Ptr <FeatureDetector>之间的区别



SiftFeatureDetector() 和 Ptr 有什么区别?它们显然都具有相同的功能。opencv教程使用SiftFeatureDetector,但是当点击官方文档时,他们使用Ptr并且没有提到SiftFeatureDetector(),所以我无法阅读它。就像在教程中一样,他们使用了这个:int minHessian = 400; SurfFeatureDetector detector( minHessian );,我不知道 minHessian 应该做什么。

我也在同一张图像上尝试了它们,它们都有相同的结果,那为什么它们不同呢?

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;

}

谢谢

编辑:请参阅下面评论中@gantzer89更正。(为了历史清晰起见,将我的原文保留在原处。


根据我的一般经验,使用 FeatureDetector::create() 语法(在您引用的"官方文档"中讨论)允许在运行时通过参数文件灵活地指定算法,而更具体的类,如 SiftFeatureDetector,提供了更多自定义机会。

create() 方法从一组默认的算法特定参数开始,而特定于算法的类允许在构造时自定义这些参数。 因此,create() 方法将默认值分配给 minHessian,而 SiftFeatureDetector 构造函数提供了选择 minHessian 值的机会。

根据经验,如果要快速试验要使用的算法,请使用 create()语法,如果要尝试微调特定算法,请使用特定于算法的类构造函数。

最新更新