opencv SURF、SIFT的使用
2015-04-15 08:58
190 查看
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/nonfree/features2d.hpp> #include <opencv2/legacy/legacy.hpp> int main() { cv::Mat ima1=cv::imread("D:\\DEMO\\penpal.jpg"); cv::Mat ima2=cv::imread("D:\\DEMO\\res.jpg"); // 检测surf特征点 cv::vector<cv::KeyPoint> kp1 , kp2 ; /*SurfFeatureDetector detector( 400 ) ; detector.detect( image1 , kp1 ); detector.detect( image2 , kp2 );*/ cv::SiftFeatureDetector sift( 2500 ); sift.detect(ima1 , kp1); sift.detect(ima2 , kp2); //显示surf检测后的结果 cv::Mat dstimg2; drawKeypoints( ima2 , kp2 , dstimg2 ); imshow("image2 keypoints" , dstimg2 ); cv::Mat dstimg1; drawKeypoints( ima1 , kp1 , dstimg1 ); imshow("image1 keypoints" , dstimg1 ); //输出surf检测的结果 cv::vector<cv::KeyPoint> :: iterator kpCounts ; for( kpCounts = kp2.begin() ; kpCounts != kp2.end() ; kpCounts++ ) { std::cout<<"angle:"<<kpCounts->angle<<"\t" << kpCounts->class_id<<"\t"<<kpCounts->octave<<"\t"<< kpCounts->pt<<"\t"<<kpCounts->response<<"\n"; } // 描述surf特征点 cv::SurfDescriptorExtractor surfDesc ; cv::Mat descriptros1 , descriptros2 ; surfDesc.compute( ima1 , kp1 , descriptros1 ); surfDesc.compute( ima2 , kp2 , descriptros2 ); // 计算匹配点数 cv::BruteForceMatcher<cv::L2<float>>matcher ; cv::vector<cv::DMatch> matches ; matcher.match( descriptros1 , descriptros2 , matches ); cv::Mat imageMatches; drawMatches( ima1 ,//输入图片1 kp1 ,//输入图片1的提取的特征点 ima2 , //输入图片2 kp2 , //输入图片2的提取出的特征点 matches ,//使用match函数获得的匹配特征点 imageMatches ,//输出图片 cv::Scalar(255,0,0)//画线颜色 ); imshow("image2" , imageMatches); cv::waitKey( 0 ); return 0; }
相关文章推荐
- 使用openCV提取sift;surf;hog特征
- OpenCV2.4.9新版本使用问题---sift,surf无法使用
- OpenCV2.4.9新版本使用问题---sift,surf无法使用
- OpenCV3如何使用SIFT和SURF Where did SIFT and SURF go in OpenCV 3?
- 使用RANSAC提纯SIFT和SURF特征点,达到鲁棒匹配的效果(OpenCV 2.4.13下,源码)
- python3.5 opencv3.1 不能使用sift, surf。
- opencv 特征点提取算法 SIFT SURF ORB FAST LBP学习(一)
- 使用OPENCV自带的sift提取特征
- OpenCV3.1 xfeatures2d::SIFT 使用
- 在OpenCV for Android 2.4.5中使用SURF(nonfree module)
- Opencv Sift和Surf特征实现图像无缝拼接生成全景图像
- OpenCV3.1使用SIFT
- opencv下SIFT使用
- OpenCV中feature2D学习——SURF和SIFT算子实现特征点检测
- OpenCV教程(47) sift特征和surf特征
- OpenCV中feature2D学习——SIFT和SURF算子实现特征点提取与匹配
- Python-OpenCV:sift(),SURF() 特征提取
- Opencv Sift和Surf特征实现图像无缝拼接生成全景图像
- opencv2.4.6版本下使用sift等特征
- OpenCV中feature2D学习——SIFT和SURF算法实现目标检测