图片特征匹配仿射变换
class ImageFeature {
public:
void BFMatch_demo(Mat& image, Mat& image2);
};
// ImageFeature ScanToPointCloud2Converter
//todo 图片匹配
void ScanToPointCloud2Converter::BFMatch_demo(Mat& image1, Mat& image2) {
// 1 初始化特征点和描述子,ORB
std::vector<KeyPoint> keypoints1, keypoints2;
Mat descriptors1, descriptors2;
Ptr<ORB> orb = ORB::create();
// 2 提取 Oriented FAST 特征点
orb->detect(image1, keypoints1);
orb->detect(image2, keypoints2);
// 3 根据角点位置计算 BRIEF 描述子
orb->compute(image1, keypoints1, descriptors1);
orb->compute(image2, keypoints2, descriptors2);
// 4 对两幅图像中的BRIEF描述子进行匹配,使用 Hamming 距离
vector<DMatch> matches;
BFMatcher bfmatcher(NORM_HAMMING);
bfmatcher.match(descriptors1, descriptors2, matches);
// 5 匹配对筛选
double min_dist = 1000, max_dist = 0;
// 找出所有匹配之间的最大值和最小值
for (int i =