SIFT匹配算法分析(Practical OpenCV)
2014-04-13 23:20
393 查看
1、源程序
#include<opencv2/opencv.hpp> #include<opencv2/highgui/highgui.hpp> #include<opencv2/nonfree/features2d.hpp> #include<opencv2/features2d/features2d.hpp> using namespace std; using namespace cv; int main() { Mat train=imread("OpticalFlow0.jpg"),train_g; cvtColor(train,train_g,CV_RGB2GRAY); vector<KeyPoint> train_kp; Mat train_desc; SiftFeatureDetector featureDetector; featureDetector.detect(train_g,train_kp); SiftDescriptorExtractor featureExtractor; featureExtractor.compute(train_g,train_kp,train_desc); BFMatcher matcher(NORM_L2); vector<Mat> train_desc_collection(1,train_desc);//?????????? matcher.add(train_desc_collection); matcher.train(); Mat test=imread("OpticalFlow1.jpg");//初始化 Mat test_g; cvtColor(test,test_g,CV_RGB2GRAY); vector<KeyPoint> test_kp; Mat test_desc; featureDetector.detect(test_g,test_kp); featureExtractor.compute(test_g,test_kp,test_desc); vector<vector<DMatch> > matches; matcher.knnMatch(test_desc,matches,2); vector<DMatch> good_matches; for(int i=0;i<matches.size();i++) { if(matches[i][0].distance<0.6*matches[i][1].distance) good_matches.push_back(matches[i][0]); } Mat img_show; drawMatches(test,test_kp,train,train_kp,good_matches,img_show); imshow("Matches",img_show); waitKey(); return 1; }
2
相关文章推荐
- 模式匹配之常见匹配算法---SIFT/SURF、haar特征、广义hough变换的特性对比分析
- 9.4 【OpenCV】 基于 ransac 算法的 sift 特征匹配程序(开发环境为OpenCV2.3.1+VS2010)
- SIFT算法原理与OpenCV源码分析3:关键点搜索与定位
- 【视觉=立体视觉】立体匹配算法 StereoBM/StereoSGBM/StereoVar(OpenCV中源码分析)+SAD块匹配算法+GC算法+HH算法
- 【OpenCV】 基于 ransac 算法的 sift 特征匹配程序(开发环境为OpenCV2.3.1+VS2010)
- SIFT算法原理与OpenCV源码分析4:方向赋值
- SIFT算法原理与OpenCV源码分析5:关键点描述
- SIFT特征点算法源码分析(opencv)
- SIFT算法原理与OpenCV源码分析6:OpenCV实现SIFT算法,特征检测器FeatureDetector
- OpenCV】 基于 ransac 算法的 sift 特征匹配程序(开发环境为OpenCV2.3.1+VS2010)
- OpenCV图像匹配算法之sift
- 图像处理中,SIFT,FAST,MSER,STAR等特征提取算法的比较与分析(利用openCV实现)
- opencv中SIFT匹配对于误匹配点RANSAC算法接口的使用
- 图像处理中,SIFT,FAST,MSER,STAR等特征提取算法的比较与分析(利用openCV实现)
- 【OpenCV】 基于 ransac 算法的 sift 特征匹配程序(开发环境为OpenCV2.3.1+VS2010)
- 经典的图像匹配算法----SIFT
- sift特征匹配算法总结(转)
- 【opencv】双目匹配代码分析
- LBD算法 - Graph matching 图匹配算法分析
- OpenCV--SIFT算法检测特征点