SIFT算法描述
SIFT(Scale-invariant feature transform)
是一种检测局部特征的算法,该算法通过求一幅图中的特征点(interest points,or corner points)及其有关scale
和 orientation
的描述子得到特征并进行图像特征点匹配
这个算法具有比较良好的尺度不变性和旋转不变形
KeyPoint
KeyPoint
类的成员变量和描述
class KeyPoint
{
Point2f pt; //特征点坐标
float size; //特征点邻域直径
float angle; //特征点的方向,值为0~360,负值表示不使用
float response; //特征点的响应强度,代表了该点是特征点的稳健度,可以用于后续处理中特征点排序
int octave; //特征点所在的图像金字塔的层组
int class_id; //用于聚类的id
}
特征点主要保存了特征点的位置、领域直径、方向、响应强度、金字塔的层组、聚类ID
DMatch
DMatch
,相信用过FAST、SURF、ORB
等特征点匹配和识别算法的都遇到过这个类型,这个类型最主要的就是存储了两个特征点在各自keyPoints
中的下标值,然后通过drawMatches
的API实现两张图片的特征点连线。
对于如下的代码:
Mat input1 = imread("img2.jpg", 0);
Mat input2 = imread("img1.jpg", 0);
SiftFeatureDetector detector;
vector<KeyPoint> keypoints1, keypoints2;
detector.detect(input1, keypoints1);
detector.detect(input2, keypoints2);
SiftDescriptorExtractor extractor;
Mat descriptor1, descriptor2;
BruteForceMatcher<L2<float>> matcher;