在以前版本中,surf和sift
1> interestPoints.cpp
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(135): error C2039: 'SurfFeatureDetector' : is not a member of 'cv'
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(135): error C2065: 'SurfFeatureDetector' : undeclared identifier
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(135): error C2146: syntax error : missing ';' before identifier 'surf'
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(135): error C3861: 'surf': identifier not found
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(137): error C2065: 'surf' : undeclared identifier
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(137): error C2228: left of '.detect' must have class/struct/union
1> type is ''unknown-type''
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(151): error C2039: 'SiftFeatureDetector' : is not a member of 'cv'
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(151): error C2065: 'SiftFeatureDetector' : undeclared identifier
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(151): error C2146: syntax error : missing ';' before identifier 'sift'
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(151): error C3861: 'sift': identifier not found
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(157): error C2065: 'sift' : undeclared identifier
1>d:\visual studio 2010\exercises\opencv2\myinterestpoints\interestpoints.cpp(157): error C2228: left of '.detect' must have class/struct/union
1> type is ''unknown-type''
1>
1>Build FAILED.
产生错误的原因就是 sift 和 surf算法已经写到#include 中,所以需要把头文件替换一下, 然后又回出现错误:
1> All outputs are up-to-date.
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
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
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 -》 确定 即可