基于opencv的特征点匹配法
来源:互联网 发布:导弹坐标系转换软件 编辑:程序博客网 时间:2024/05/22 08:22
基于opencv的特征点匹配法
基于opencv的特征点匹配方法已经有很多博文了
我也是参考了其中几篇
给出链接供大家参考
Opencv2.4.9源码分析——SIFT
Opencv学习笔记(六)SURF学习笔记
还有一篇链接居然失效了~囧
不过我看他们的文章基本是基于其中一个算法的(比如SIFT),我这个代码中给出了使用不同算子特征的方法。
#include <opencv2/core/core.hpp>#include <opencv2/features2d/features2d.hpp>#include <opencv2/highgui/highgui.hpp>#include <opencv2/nonfree/features2d.hpp>#include <opencv2/legacy/legacy.hpp>#include <iostream>using namespace cv;using namespace std;int main(){double time = (double)cvGetTickCount();Mat image1=imread("0.jpg");Mat image2=imread("1.jpg");//Mat image1=imread("1.jpg");//Mat image2=imread("2.jpg");Mat reimage1;Mat reimage2;//undistortion//相机内参Mat intrinsic = (Mat_<double>(3,3) << 621.1558, 0, 327.3255, 0, 618.2676, 238.3404, 0, 0, 1.0000);//cout<<intrinsic<<endl;//相机畸变参数Mat distortion= (Mat_<double>(4,1) << 0.100995533983367 ,-0.179776019431878 , 0.000775515546919460, -0.00493615870309803);//这里是去畸变,当然需要按照你自己的摄像机调整内参和畸变参数,reimage是去畸变后的图片undistort(image1,reimage1,intrinsic,distortion);undistort(image2,reimage2,intrinsic,distortion);//imshow("undistortion",reimage1);// 检测特征点vector<KeyPoint> keypoints1,keypoints2; //在这里切换不同的detector//OrbFeatureDetector detector(200);SurfFeatureDetector detector(30);//FastFeatureDetector detector(25);//SurfFeatureDetector detector(50);//detector.detect(reimage1, keypoints1);//detector.detect(reimage2, keypoints2);detector.detect(image1, keypoints1);detector.detect(image2, keypoints2);// 描述特征点//这里选择不同的descriptor//OrbDescriptorExtractor Desc;SurfDescriptorExtractor Desc;//SiftDescriptorExtractor Desc;//BriefDescriptorExtractor Desc;Mat descriptros1,descriptros2;//Desc.compute(reimage1,keypoints1,descriptros1);//Desc.compute(reimage2,keypoints2,descriptros2);Desc.compute(image1,keypoints1,descriptros1);Desc.compute(image2,keypoints2,descriptros2);// 计算匹配点数BruteForceMatcher<L2<float> >matcher;vector<DMatch> matches;matcher.match(descriptros1,descriptros2,matches);//调整topN个点int n=100;std::nth_element(matches.begin(),matches.begin()+n,matches.end());matches.erase(matches.begin()+n+1,matches.end());// 画出匹配图Mat imageMatches;//drawMatches(reimage1,keypoints1,reimage2,keypoints2,matches,imageMatches,Scalar(255,0,0));drawMatches(image1,keypoints1,image2,keypoints2,matches,imageMatches,Scalar(255,0,0));//namedWindow("Match");// time counttime = (double)cvGetTickCount() - time;//输出运行时间printf( "run time = %gms\n", time/(cvGetTickFrequency()*1000) );imshow("Match",imageMatches);//waitkey不要忘记哦waitKey();return 0;}
ps:第一次写博客,格式还比较烂~慢慢练吧~
0 0
- 基于opencv的特征点匹配法
- OpenCV-基于特征点的图像匹配
- opencv-基于ORB特征点匹配
- 基于OpenCV的简单图片特征匹配
- Android Jni OpenCV-基于ORB算法特征点匹配
- 基于特征点匹配的车辆跟踪
- 特征点匹配应用——图像拼接的原理与基于OpenCV的实现
- 一种基于特征点匹配的图像检索方法的opencv实现
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- 【opencv】特征点提取和匹配的通用方法
- OpenCV中特征点提取和匹配的通用方法
- 一阶谓词逻辑系统的一个扩充
- Linux大神养成之正则表达式(grep,sed)
- Echarts ajax动态加载json数据
- 3. Browser 对象 - Navigator 对象
- 关于动画的切换可以用UIImageView中的属性来实现。
- 基于opencv的特征点匹配法
- 使用SQLServer2008R2进行缓存依赖通知需要注意事项
- coreData实现增删除改查
- VS2010装了VC助手后卡死,连系统界面都卡死界面方案
- NavigationControllerr滑动返回
- 喷水装置(一)【贪心】
- AMBA片上总线在基于IP复用的SoC设计中的应用
- 手把手创建自定义的分层的maven-archetype
- 栈