OpenCV3.0 图像匹配问题
初学OpenCV,用的是3.0版本,在学习图像特征点匹配时发现:
1.原来版本中获取特征点使用的是:
#include <opencv2/nonfree/nonfree.hpp>
int minHessian = 4;
SurfFeatureDetector detector( minHessian );
vector<KeyPoint> keyPoint1;
detector.detect( srcImage1, keyPoint1 );
但3.0中并没有这个头文件,所有没法使用SurfFeatureDetector 类
更改使用:
int minHessian = 40;
vector<KeyPoint> keypoints;
Ptr<FeatureDetector> dector = FastFeatureDetector::create(minHessian);
dector->detect(g_srcImage,keypoints);
这样貌似是可以的,但貌似算子不能超过40
但是在计算特征向量跟向量匹配的时候,原来版本给出的方法是:
#include <opencv2/features2d/features2d.hpp" >
#include<opencv2/legacy/legacy.hpp>
SurfDescriptorExtractor extractor;
Mat descriptors1, descriptors2;
extractor.compute( srcImage1, keyPoint1, descriptors1 );
BruteForceMatcher< L2<float> > matcher;
vector< DMatch > matches;
matcher.match( descriptors1, descriptors2, matches );
同样的,SDK中没有头文件legacy.hpp也没有提供相应的lib库链接,SurfDescriptorExtractor 跟BruteForceMatcher都无法调用
仿照特征点的方法做了如下更改:
Mat descriptor1,descriptor2;
DescriptorExtractor ectrcator;
ectrcator.compute(g_srcImage,keypoints_jugg1,descriptor1);
ectrcator.compute(g_dstImage,keypoints_jugg2,descriptor2);
BFMatcher matcher(NORM_L2);
vector<DMatch> matches;
matcher.match(descriptor1, descriptor2,matches);
但是运行报错,提示The function/feature is not implement() int cv::Feature2D::detectAndCompure
所有请教下3.0版本下如何正确进行图像特征点匹配操作?