opencv3中SurfFeatureDetectorSurfDescriptorExtractorBruteForceMatcher的使用

Posted 拒绝爆肝

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了opencv3中SurfFeatureDetectorSurfDescriptorExtractorBruteForceMatcher的使用相关的知识,希望对你有一定的参考价值。

opencv2中SurfFeatureDetector、SurfDescriptorExtractor、BruteForceMatcher在opencv3中发生了改变。具体如何完成特征点匹配呢?示例如下:

//寻找关键点

int minHessian = 700;

Ptr<SURF>detector = SURF::create(minHessian);

detector->detect( srcImage1, keyPoint1 );

detector->detect( srcImage2, keyPoints2 );

 

//绘制特征关键点

Mat img_keypoints_1; Mat img_keypoints_2;

drawKeypoints( srcImage1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT );

drawKeypoints( srcImage2, keypoints_2, img_keypoints_2, Scalar::all(-1), DrawMatchesFlags::DEFAULT );

 

//显示效果图

imshow("特征点检测效果图1", img_keypoints_1 );

imshow("特征点检测效果图2", img_keypoints_2 );

 

//计算特征向量

Ptr<SURF>extractor = SURF::create();

Mat descriptors1, descriptors2;

extractor->compute( srcImage1, keyPoint1, descriptors1 );

extractor->compute( srcImage2, keyPoints2, descriptors2 );

 

//使用BruteForce进行匹配

Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce");

std::vector< DMatch > matches;

matcher->match( descriptors1, descriptors2, matches );

 

//绘制从两个图像中匹配出的关键点

Mat imgMatches;

drawMatches( srcImage1, keyPoint1, srcImage2, keyPoints2, matches, imgMatches );//进行绘制

 

//显示

imshow("匹配图", imgMatches );

 

3.x的特征检测:

  • 算法:SURF,SIFT,BRIEF,FREAK 
  • 类:cv::xfeatures2d::SURF
  1. cv::xfeatures2d::SIFT
  2. cv::xfeatures::BriefDescriptorExtractor
  3. cv::xfeatures2d::FREAK
  4. cv::xfeatures2d::StarDetector
  • 需要进行以下几步
  1. 加入opencv_contrib
  2. 包含opencv2/xfeatures2d.hpp
  3. using namepsace cv::xfeatures2d
  4. 使用create(),detect(),compute(),detectAndCompute()

 

以上是关于opencv3中SurfFeatureDetectorSurfDescriptorExtractorBruteForceMatcher的使用的主要内容,如果未能解决你的问题,请参考以下文章

opencv3 学习 一

opencv3中SurfFeatureDetectorSurfDescriptorExtractorBruteForceMatcher的使用

树莓派中编译OpenCV3.4.1和OpenCvSharp

ubuntu中怎么使用opencv3.0.0

OpenCV3.3 深度学习模块-对象检测演示

OpenCV3学习笔记整理(一期)