opencv3.3.0找不到SurfFeatureDetector

在上一篇配置好opencv3.3.0的opencv_contrib扩展包的基础上

在学习SURF算法时,按照书上的程序写

//输入图像
    Mat image = imread("E:\\paper_and_code\\20180906\\SURF_test_1008\\1.jpg");

Mat outimage;//输出图像
    vector<KeyPoint> keyPoints;//关键点

SurfFeatureDetector surf(3000);//设置SURF特征检测器
    surf.detect(image, keyPoints);//检测图像中的SURF特征点

但是出现很多错误(如下):

Error    C2259    'cv::xfeatures2d::SURF': cannot instantiate abstract class    
Error    C2664    'cv::xfeatures2d::SURF::SURF(cv::xfeatures2d::SURF &&)': cannot convert argument 1 from 'int' to 'const cv::xfeatures2d::SURF &'    
Error (active)        no instance of constructor "cv::xfeatures2d::SURF::SURF" matches the argument list    

Error (active)        object of abstract class type "cv::xfeatures2d::SURF" is not allowed:   

      在查找了资料后了解到,在opencv3.3的版本中SurfFeatureDetector是SURF类 ,但在class SURF 中有纯虚函数,所以SurfFeatureDetector不能实例化,也就是SurfFeatureDetector不能直接定义对象。

      把上述的代码改进为如下代码就可以使用了

//输入图像
    Mat image = imread("E:\\paper_and_code\\20180906\\SURF_test_1008\\1.jpg");

Mat outimage;//输出图像
    vector<KeyPoint> keyPoints;//关键点
    Mat dstImage;

Ptr<SurfFeatureDetector> detector = SurfFeatureDetector::create(minHessian);//设置SURF特征检测器
    detector->detectAndCompute(image, Mat(), keyPoints, dstImage);//检测图像中的SURF特征点

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值