GMS特征匹配 原文和代码详细解读GMS: Grid-based Motion Statistics for Fast, Ultra-robust Feature Correspondence

GMS: Grid-based Motion Statistics for Fast, Ultra-robust Feature Correspondence 代码解读

 
论文原文地址:GMS: Grid-based Motion Statistics for Fast, Ultra-robust Feature Correspondence
代码地址:github
 

1 论文核心思路

SIFT-GMS对比
 论文认为:匹配对应该是平滑的,对于true match pair(l1,r1),l1附近的特征点对应的匹配点也应该在r1附近.
 ① 利用上面的平滑性质,建立统计分析模型(二项分布),过滤ORB matches中的false matches;
 ② 通过划分栅格来加速真假判断过程,两张图像各划分成m * m块,只需要对各块内及邻块的Feature统计,m建议是20;
 ③ 对于匹配块(pl1,pr1),对相邻的n * n块,分别进行统计,比如统计pl1的左上块与pr1的左上块的匹配数目,其他类似,以共同验证(pl1,pr1)是否是正确匹配块.这里n建议是3.
 ④ 论文验证了这个思路的可行性.
 

1.1 GMS系统概述

下图中,红星表示的是GMS,可以看出,确实很厉害,精度和时间都很好。
GMS目标
下面这张图是GMS整体思路的总结,主要利用了平滑性质
全文概述
 

1.2 统计概率模型

下图是论文提到的统计概率模型,公式符号较多,建议结合论文阅读
统计概率模型1
下图中,最大化P是为了将false

  • 5
    点赞
  • 55
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
由于orb特征点匹配的代码比较长,我将简要介绍其实现思路并给出代码框架。 ORB特征点是一种旋转不变性和尺度不变性的特征点,可以用于图像匹配和物体识别等任务。ORB特征点匹配的基本流程如下: 1. 对两张图像进行ORB特征点提取和描述子计算。 2. 利用shi-tomasi算法对提取的特征点进行筛选,保留最优的特征点。 3. 利用GMS算法对匹配结果进行筛选,去除误匹配。 下面是代码框架: ```c #include <opencv2/opencv.hpp> #include <opencv2/features2d.hpp> #include <opencv2/xfeatures2d.hpp> #include <opencv2/highgui.hpp> #include <vector> using namespace std; using namespace cv; using namespace cv::xfeatures2d; int main() { // 读取两张图像 Mat img1 = imread("img1.jpg", CV_LOAD_IMAGE_GRAYSCALE); Mat img2 = imread("img2.jpg", CV_LOAD_IMAGE_GRAYSCALE); // 定义ORB特征点检测器和描述子提取器 Ptr<FeatureDetector> detector = ORB::create(); Ptr<DescriptorExtractor> extractor = ORB::create(); // 提取ORB特征点和描述子 vector<KeyPoint> kp1, kp2; Mat desc1, desc2; detector->detect(img1, kp1); extractor->compute(img1, kp1, desc1); detector->detect(img2, kp2); extractor->compute(img2, kp2, desc2); // 利用shi-tomasi算法对特征点进行筛选 // ... // 进行特征点匹配 BFMatcher matcher(NORM_HAMMING); vector<DMatch> matches; matcher.match(desc1, desc2, matches); // 利用GMS算法对匹配结果进行筛选 // ... // 绘制匹配结果 Mat img_matches; drawMatches(img1, kp1, img2, kp2, good_matches, img_matches); // 显示匹配结果 namedWindow("Matches", WINDOW_NORMAL); imshow("Matches", img_matches); waitKey(0); return 0; } ``` 其中,shi-tomasi算法和GMS算法的实现可以参考下面的代码: ```c // 利用shi-tomasi算法对特征点进行筛选 vector<Point2f> corners1, corners2; vector<KeyPoint> kp1_new, kp2_new; for (int i = 0; i < kp1.size(); i++) { corners1.push_back(kp1[i].pt); } for (int i = 0; i < kp2.size(); i++) { corners2.push_back(kp2[i].pt); } vector<uchar> status; vector<float> err; calcOpticalFlowPyrLK(img1, img2, corners1, corners2, status, err); for (int i = 0; i < kp1.size(); i++) { if (status[i] && kp1[i].response >= min_response) { kp1_new.push_back(kp1[i]); kp2_new.push_back(KeyPoint(corners2[i], kp2[i].size)); } } kp1 = kp1_new; kp2 = kp2_new; // 利用GMS算法对匹配结果进行筛选 vector<DMatch> good_matches; vector<Point2f> pts1, pts2; for (int i = 0; i < matches.size(); i++) { pts1.push_back(kp1[matches[i].queryIdx].pt); pts2.push_back(kp2[matches[i].trainIdx].pt); } GMSMatcher gms; gms.setPatternSize(8); gms.setThreshold(0.9); gms.run(pts1, img1.size(), pts2, img2.size(), matches, good_matches); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值