(关于解决方案2:https://blog.csdn.net/IT_flying625/article/details/103231212)
在opecv3.0中,SURF/SIFT 以及其它的一些东西被移动到了独立的库(opencv_contrib repo)中
所以需要使用cmake重新编译
一、下载
为了确保不会报错,这里使用OpenCV版本和OpenCV Contrib版本保持一致
1.OpenCV Contrib https://github.com/opencv/opencv_contrib 3.4.8
2. OpenCV https://github.com/opencv/opencv 3.4.8
3. cmake-gui下载地址:http://www.cmake.org/cmake/resources/software.html
二、使用cmake生成OpenCV.sln
打开cmake-gui
在where is the source code选择opencv的安装目录,我的是D:opencv3opencvsources
在where to build the binaries里面选择要将opencv编译到的目录下面,我的是:D:opencv3opencvmybuild
点击configure,在弹出的对话框内选择 Visual Studio 2013和default参数,点击finish。
这个时候cmake会开始编译不知道什么东西,然后会在屏幕中间出现一堆参数包括Name和Value,在其中找到Name为OPENCVEXTRAMODULESPATH的参数,然后把它的Value设置为opencvcontrib的路径,我的是D:/Files/Codes/Tracking/Exp/opencvcontrib-master/opencvcontrib-master/modules
注意,不要因为路径报错https://blog.csdn.net/IT_flying625/article/details/103065993
三、用VS编译生成debug和release库
打开D:opencv3opencvmybuild目录下的OpenCV.sln
编译debug版本库:在“解决方案'OpenCV'(141个项目)”上面点击右键-->重新生成解决方案。
找到CMakeTargets中的INSTALL,然后右键选择“仅限于项目”-->“仅生成INSTALL”,然后就在D:opencv3opencvmybuildinstall中发现了许多东东。
四、重新配置自己的项目
VC 目录-->包含目录,添加: D:opencv3opencvmybuildinstallinclude
VC 目录-->库目录,添加: D:opencv3opencvmybuildinstallx86vc12lib D:opencv3opencvmybuildinstallx86vc12staticlib
链接器-->输入-->附加依赖项,添加:
opencv_bgsegm300d.lib opencv_bioinspired300d.lib opencv_calib3d300d.lib opencv_ccalib300d.lib opencv_core300d.lib opencv_datasets300d.lib opencv_face300d.lib opencv_features2d300d.lib opencv_flann300d.lib opencv_hal300d.lib opencv_highgui300d.lib opencv_imgcodecs300d.lib opencv_imgproc300d.lib opencv_latentsvm300d.lib opencvlinedescriptor300d.lib opencv_ml300d.lib opencv_objdetect300d.lib opencv_optflow300d.lib opencv_photo300d.lib opencv_reg300d.lib opencv_rgbd300d.lib opencv_saliency300d.lib opencv_shape300d.lib opencv_stereo300d.lib opencv_stitching300d.lib opencv_superres300d.lib opencvsurfacematching300d.lib opencv_text300d.lib opencv_tracking300d.lib opencv_ts300d.lib opencv_video300d.lib opencv_videoio300d.lib opencv_videostab300d.lib opencv_xfeatures2d300d.lib opencv_ximgproc300d.lib opencv_xobjdetect300d.lib opencv_xphoto300d.lib ippicvmt.lib