opencv_C++ SIFT::create( ) 函数

SIFT算法需要安装额外的扩展模块,安装步骤和注意事项见我博客:https://blog.csdn.net/qq_27396861/article/details/88095820

cv::xfeatures2d::SIFT::create( int nfeatures = 0, int nOctaveLayers = 3,
    double constrastThreshold = 0.04, double edgeThreshold = 10,
    double sigma = 1.5 )

(1)nfeatures,保留的最佳特性的数量。特征按其得分进行排序(以SIFT算法作为局部对比度进行测量);
(2)nOctavelLayers,高斯金字塔最小层级数,由图像自动计算出;
(3)constrastThreshold,对比度阈值用于过滤区域中的弱特征。阈值越大,检测器产生的特征越少。;
(4)edgeThreshold ,用于过滤掉类似边缘特征的阈值。 请注意,其含义与contrastThreshold不同,即edgeThreshold越大,滤出的特征越少;
(5)sigma,高斯输入层级, 如果图像分辨率较低,则可能需要减少数值。

示例:

#include <opencv2/opencv.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <opencv2/xfeatures2d/nonfree.hpp>
#include <iostream>
using namespace cv;
using namespace cv::xfeatures2d;
using namespace std;

int main()
{
	Mat srcImage = imread("curry_dlt.jpg");

	int numFeatures = 20;
	Ptr<SIFT> dectector = SIFT::create(numFeatures);

	vector<KeyPoint> keypoints;
	dectector->detect(srcImage, keypoints, Mat());
	printf("Total keypoints: %d\n", keypoints.size());

	Mat keypoint_img;
	drawKeypoints(srcImage, keypoints, keypoint_img, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
	imshow("keypoint_img", keypoint_img);

	waitKey(0);
	return 0;
}

效果图:
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值