当前位置:   article > 正文

opencv2.4.5正确调用SurfFeatureDetector,SiftFeatureDetector_‘siftfeaturedetector’ is not a member of ‘cv’

‘siftfeaturedetector’ is not a member of ‘cv’

       在以前版本中,surf和sift算法都是在头文件#include <opencv2/features2d/features2d.hpp>中,但在新的opencv版本出来后,如果仍然使用这个头文件就会出现编译错误如下:     

  1. 1> interestPoints.cpp
  2. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(135): error C2039: 'SurfFeatureDetector' : is not a member of 'cv'
  3. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(135): error C2065: 'SurfFeatureDetector' : undeclared identifier
  4. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(135): error C2146: syntax error : missing ';' before identifier 'surf'
  5. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(135): error C3861: 'surf': identifier not found
  6. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(137): error C2065: 'surf' : undeclared identifier
  7. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(137): error C2228: left of '.detect' must have class/struct/union
  8. 1> type is ''unknown-type''
  9. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(151): error C2039: 'SiftFeatureDetector' : is not a member of 'cv'
  10. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(151): error C2065: 'SiftFeatureDetector' : undeclared identifier
  11. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(151): error C2146: syntax error : missing ';' before identifier 'sift'
  12. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(151): error C3861: 'sift': identifier not found
  13. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(157): error C2065: 'sift' : undeclared identifier
  14. 1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(157): error C2228: left of '.detect' must have class/struct/union
  15. 1> type is ''unknown-type''
  16. 1>
  17. 1>Build FAILED.
     产生错误的原因就是 sift 和 surf算法已经写到#include <opencv2/nonfree/features2d.hpp>中,所以需要把头文件替换一下, 然后又回出现错误:

  1. 1> All outputs are up-to-date.
  2. 1>interestPoints.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::SIFT::SIFT(int,int,double,double,double)" (??0SIFT@cv@@QAE@HHNNN@Z) referenced in function _main
  3. 1>interestPoints.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::SURF::SURF(double,int,int,bool,bool)" (??0SURF@cv@@QAE@NHH_N0@Z) referenced in function _main
  4. 1>D:\visual studio 2010\Exercises\opencv2\MyInterestPoints\Debug\MyInterestPoints.exe : fatal error LNK1120: 2 unresolved externals
     所以继续排查原因,知道原来没有把 opencv_nonfree244d.lib 加入lib库中。

     添加方法: View -》 Project Manager,

 

 在Property Manager窗口中,右键Debug|Win32,选择Properties,

      Linker -》 Input -》 Additional Dependencies -》edit


  添加opencv_nonfree244d.lib -》 确定 即可



声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/743187
推荐阅读
相关标签
  

闽ICP备14008679号