三维重建(二)Sift特征提取与匹配
来源:互联网 发布:javascript特效实例 编辑:程序博客网 时间:2024/05/16 01:52
抱歉,之前代码中
//挑选匹配的最好的前100个 nth_element(matches.begin(), matches.begin() + 99, matches.end()); matches.erase(matches.begin() + 99, matches.end());
写错了,把99写成00了,所以看不到匹配结果,这里改过来了
————————————————————————————————
这里我主要写了用Opencv 实现Sift特征提取与匹配的代码,如果想看Sift特征的详细描述,请看原文《Distinctive Image Features》或者我最近又写了三篇关于SIFT算法的详细描述
SIFT算法详解(1)综述与尺度空间检测
SIFT算法详解(2)极值点的精确定位与特征点方向的计算
SIFT算法详解(3)特征点描述符的生成
这里面也有我参考的一些资源
下面是我的代码:
//使用Opencv实现SIFT特征点检测//lhc 2016-07-08#include <opencv2\highgui\highgui.hpp>#include <opencv2\features2d\features2d.hpp>#include <opencv2\imgproc\imgproc.hpp>#include <opencv2\nonfree\nonfree.hpp>#include <opencv2/legacy/legacy.hpp> #include <iostream>using namespace std;using namespace cv;int main(){ Mat image1 = imread("G:\\ET\\et000.jpg"); Mat image2 = imread("G:\\ET\\et001.jpg"); //Sift检测器 SiftFeatureDetector detector; //保存两幅图像得到的特征点 vector<KeyPoint> image1KeyPoint, image2KeyPoint; //检测特征点 detector.detect(image1, image1KeyPoint); detector.detect(image2, image2KeyPoint); //把特征点画在两幅新图上 Mat imageOutput1; Mat imageOutput2; drawKeypoints(image1, image1KeyPoint, imageOutput1, Scalar(0, 255, 0)); drawKeypoints(image2, image2KeyPoint, imageOutput2, Scalar(0, 255, 0)); //Sift特征描述提取 SiftDescriptorExtractor extractor; Mat descriptor1, descriptor2; //得到Sift特征描述符 extractor.compute(imageOutput1, image1KeyPoint, descriptor1); extractor.compute(imageOutput2, image2KeyPoint, descriptor2); //暴力匹配 BruteForceMatcher<L2<float>> matcher; vector<DMatch> matches; matcher.match(descriptor1, descriptor2, matches); //挑选匹配的最好的前100个 nth_element(matches.begin(), matches.begin() + 99, matches.end()); matches.erase(matches.begin() + 99, matches.end()); //画出匹配线 Mat image_matched; drawMatches(imageOutput1, image1KeyPoint, imageOutput2, image2KeyPoint, matches, image_matched); imshow("image1", imageOutput1); imshow("image2", imageOutput2); imshow("image_matched", image_matched); waitKey(0); return 0;}
这里有另一种Opencv的实验方法,也比较详细
另外,我试验发现Opencv自带的SIFT特征检测方法运算速度比较慢,应该是用CPU跑的,而且不开源,国外有人写了一个用GPU跑的Sift特征检测,但是没有并行化,这这里SiftGPU: A GPU Implementation of Scale Invariant Feature Transform (SIFT)
0 0
- 三维重建(二)Sift特征提取与匹配
- 三维重建(二)Sift特征提取与匹配
- SIFT特征提取与匹配
- SIFT特征提取与匹配
- 简易三维重建(二) SIFT提取特征向量
- SIFT算法的特征提取与匹配
- Opencv Sift算子特征提取与匹配
- Opencv Sift算子特征提取与匹配
- Opencv Sift算子特征提取与匹配
- SIFT特征提取,特征匹配
- opencv(30)---特征检测与匹配(1)---SIFT特征点提取
- sift图像特征提取与匹配算法代码
- sift图像特征提取与匹配算法代码
- 图像特征提取与匹配之SIFT算法
- 图像特征提取与匹配之SIFT算法
- Opencv中sift特征提取与匹配代码
- 图像特征提取与匹配之SIFT算法
- OpenCV实现SfM(一):双目三维重建(包含SIFT特征点提取)
- 使用C#(Random)随机数来制作随机字母数字混合密码生成器
- Cisco InterCloud
- YAML 语言教程
- 371. Sum of Two Integers
- java内部类总结
- 三维重建(二)Sift特征提取与匹配
- Codeforces Round #360 (Div. 1)A - NP-Hard Problem
- Android之SD卡简单的文件读写操作
- leetcode:Water and Jug Problem
- 2016sdau课程练习专题三 1008
- XMPP 学习笔记一 OpenFire与Spark安装
- PCH文件自定义NSLog及存在C文件时PCH文件定义注意事项
- 290. Word Pattern
- Android之SD卡以追加形式写文件并把文件保存到SD卡中