ORB特征点提取
2017-06-06 15:21
351 查看
其具体原理可参考:这篇博客
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/features2d/features2d.hpp> #include <iostream> using namespace cv; using namespace std; int main(int argc, char** argv) { Mat img_1 = imread("./1.jpg"); Mat img_2 = imread("./2.jpg"); // -- Step 1: Detect the keypoints using STAR Detector std::vector<KeyPoint> keypoints_1,keypoints_2; ORB orb; orb.detect(img_1, keypoints_1); orb.detect(img_2, keypoints_2); // -- Stpe 2: Calculate descriptors (feature vectors) Mat descriptors_1, descriptors_2; orb.compute(img_1, keypoints_1, descriptors_1); orb.compute(img_2, keypoints_2, descriptors_2); //-- Step 3: Matching descriptor vectors with a brute force matcher BFMatcher matcher(NORM_HAMMING); std::vector<DMatch> matches; matcher.match(descriptors_1, descriptors_2, matches); //4.对匹配结果进行筛选(依据DMatch结构体中的float类型变量distance进行筛选) float minDistance = 100; float maxDistance = 0; for (int i = 0; i < matches.size(); i++) { if (matches[i].distance < minDistance) minDistance = matches[i].distance; if (matches[i].distance > maxDistance) maxDistance = matches[i].distance; } cout << "minDistance: " << minDistance << endl; cout << "maxDistance: " << maxDistance << endl; vector<DMatch> goodMatches; for (int i = 0; i < matches.size(); i++) { if (matches[i].distance < 2 * minDistance) { goodMatches.push_back(matches[i]); } } // -- dwaw matches Mat img_mathes; drawMatches(img_1, keypoints_1, img_2, keypoints_2, goodMatches, img_mathes); // -- show imshow("Mathces", img_mathes); waitKey(0); return 0; }
相关文章推荐
- 特征提取算法--ORB
- SIFT,SURF,ORB,FAST 特征提取算法比较
- opencv上gpu版surf特征点与orb特征点提取及匹配实例
- ORB特征提取
- ORB_SLAM ORBextractor 特征点提取 opencv源码学习
- SLAM——ORB特征提取、对极约束(E\F)、单应矩阵和三角测量(一)
- ORB特征提取详解
- 基于硬件的ORB特征提取与实现(第一部分)——特征点算法仔细分析
- OpenCV2学习笔记(二十二):ORB特征提取
- OpenCV的ORB特征提取算法
- opencv上gpu版surf特征点与orb特征点提取及匹配实例
- OpenCV的ORB特征提取算法
- OpenCV的ORB特征提取算法
- SIFT,SURF,ORB,FAST 特征提取算法比较
- 基于ORB特征提取算法图像匹配 python实现
- orb特征提取
- ORB特征提取与匹配
- 关于opencv提取ORB特征时 cannot declare variable ‘orb’ to be of abstract type ‘cv::ORB问题
- 【AR实验室】mulberryAR:并行提取ORB特征
- mexopencv-利用orb feature detector 提取和匹配特征