1,opencv:比如:opencv-3.2.0-vc14.exe opencv-3.1.0.exe等。OpenCV3.2下载地址在这 里:http://opencv.org/opencv-3-2.html。
选择Windows自解压的那个连接点击进去即可下载OpenCV3.2的Windows版本。下载以后解压缩到指定目录即可。
2,opencv_contrib扩展模块下载地址,同样下载好之后先解压缩到指定目录即可。
https://github.com/opencv/opencv_contrib/releases
3.cmake: 有安装版与不安装版(直接解压就能用),哪个都行。
让你选择编译的位数与版本,根据实际情况来,(比如VS2013+ Win64的),选择好啦显示如下:
D:\opencv3\下建立两文件夹:source 和 bulId
opencv-3.2.0-vc14.exe 解压的source文件和OpenCV_contrib扩展模块放在D:\opencv3\source下
接下来:打开CMake
以下蓝色字体是版本选择不对应,导致的很多问题,也浪费很多时间:所以应该下载对应的版本。
之前一直安装出错:opencv-3.2.0和opencv_contrib-master.zip
对应版本安装成功 : opencv-3.2.0和opencv_contrib-3.2.0.zip,而且安装速度很快,不用自己去下载缺少文件。
点Configure ,之后碰到很多问题,总结下:
在自己编译OpenCV时,因为种种原因可能会导致FFmpeg或ippicv下载不成功的问题,可以通过手动配置来解决这类问题,当然也可以直接配置之后再编译。
尤其是ippicv_windows_20151201.zip,如果下载失败会报错,继续configure,多次尝试不行后可以去以下下载:
http://download.csdn.net/download/mage1120/9399406
然后放到:D:\opencv3\source\opencv\3rdparty\ippicv\downloads\windows-04e81ce5d0e329c3fbc606ae32cad44d下,继续configure就可以成功了。
【OpenCV】编译OpenCV时,FFmpeg或ippicv下载不成功的解决方案
http://blog.csdn.net/yiyuehuan/article/details/52951574
然后找到OPENCV_EXTRA_MODULE_PATH设置扩展模块的路径运行完成显示如下:
到这时候基本上第一次编译就可以顺利完成了,然后添加modules路径后进行第二次编译,这一次编译时我遇到了另一个错误:
cmakeError at cmake /opencvModule.cmake: Syntaxerror in cmake code at:C:/program files/opencv/source/cmake/opencvmodule.cmake when parsing string C:.......
Invalid escape sequence \P.
主要就是说遇到语法错误,也百度很多,发现大家的错误都是在用VC++开始编译程序的时候遇到的,只有我的是在cmake搭建环境时,最后在Stake Overflow上找到解决方案,主要是填写MODULE路径时出了错,这一步一定不要在文件夹里重复制路径,因为直接复制过来的是向后的分隔符"\",实际上应该是向前的“/”,最好双击空白处,点击“···”一步步选择文件夹的添加,或者注意与上一行路径格式一致就行。
opencv-contrib在cmake中出现下载错误的解决
opencv添加opencv_contrib失败——ocv_download
在cmake中会出现下载错误,导致config失败。
看cmake源代码知道ocv_download这个函数在使用的时候,错把PACKAGE写成filename.
修改后再次config,generate成功。
D:\opencv\opencv_contrib\modules\dnn\cmake\OpenCVFindLibProtobuf.cmake
32 行改为
ocv_download(PACKAGE "protobuf-cpp-3.1.0.tar.gz"
D:\opencv\opencv_contrib\modules\dnn_modern\CMakeLists.txt
20行改为
ocv_download(PACKAGE "v1.0.0a3.tar.gz"
D:\opencv\opencv_contrib\modules\xfeatures2d\cmake\download_boostdesc.cmake
22行改为
ocv_download(PACKAGE ${name_${id}}
D:\opencv\opencv_contrib\modules\xfeatures2d\cmake\download_vgg.cmake
16行改为
ocv_download(PACKAGE ${name_${id}}
download_boost_descriptors("${DOWNLOAD_DIR}" boost_status)
download_vgg_descriptors("${DOWNLOAD_DIR}" vgg_status)
D:\opencv3\source\cmake\OpenCVUtils.cmake等 出错原因,都错把PACKAGE写成filename.
配置成功
重新配置OpenCV,新建一个项目打开,到【视图】-》【其它窗口】-》【属性管理器】然后选择64 debug下的User Cpp从属性中打开配置窗口
错误204error C1083: 无法打开包括文件: “boostdesc_bgm.i”: No such file or directoryD:\opencv-3.2.0\source\opencv_contrib-master\modules\xfeatures2d\src\boostdesc.cpp6461 opencv_xfeatures2d
错误 248 error C1083: 无法打开包括文件: “opencv2/xfeatures2d/cuda.hpp”: No such file or directoryD:\opencv-3.2.0\source\modules\stitching\include\opencv2\stitching\detail\matchers.hpp521 opencv_stitching
错误 239 error C1083: 无法打开包括文件: “vgg_generated_120.i”: No such file or directoryD:\opencv-3.2.0\source\opencv_contrib-master\modules\xfeatures2d\src\vgg.cpp4741 opencv_xfeatures2d
错误 572error LNK1104: 无法打开文件“..\..\lib\Debug\opencv_xfeatures2d320d.lib”D:\opencv-3.2.0\bulid\modules\xfeatures2d\LINKopencv_perf_xfeatures2d
错误 631 error LNK1104: 无法打开文件“..\..\lib\Debug\opencv_xfeatures2d320d.lib”D:\opencv-3.2.0\bulid\modules\xfeatures2d\LINKopencv_test_xfeatures2d
上面三个错误导致下面的两个错误。
在以下目录添加 : D:\opencv-3.2.0\source\opencv_contrib-master\modules\xfeatures2d\src
在make时出现 opencv2/xfeatures2d/cuda.hpp:No such file or directory。也不知道为什么,在目录opencv_contrib/modules/xfeatures2d/include/opencv2/xfeatures2d/目录下有cude.hpp,但是还是提示文件不存在。最后找到了了与opencv3.2匹配的opencv_contrib3.2,进行安装,成功。
这是生成了debug与release的一个,然后切换到另一个,重做刚才的操作(整个项目上右键,重新生成解决方案。。。。。)。
分别设置好 包含目录 122>------ 已跳过生成: 项目: INSTALL, 配置: Debug x64 ------
122>没有为此解决方案配置选中要生成的项目
123>------ 已跳过生成: 项目: PACKAGE, 配置: Debug x64 ------
123>没有为此解决方案配置选中要生成的项目
========== 生成: 成功 116 个,失败 0 个,最新 0 个,跳过 7 个 ==========
1> -- Installing: D:/opencv-3.2.0/bulid/install/x64/vc12/bin/opencv_visualisationd.exe
1> -- Installing: D:/opencv-3.2.0/bulid/install/x64/vc12/bin/opencv_interactive-calibrationd.exe
1> -- Installing: D:/opencv-3.2.0/bulid/install/x64/vc12/bin/opencv_versiond.exe
========== 生成: 成功 1 个,失败 0 个,最新 0 个,跳过 0 个 ==========
包含目录:
D:\opencv3\build\install\include
D:\opencv3\build\install\include\opencv
D:\opencv3\build\install\include\opencv2
opencv3.2生成的lib文件(包括扩展部分)共有45个。
debug:
opencv_aruco320d.lib
opencv_bgsegm320d.lib
opencv_bioinspired320d.lib
opencv_calib3d320d.lib
opencv_ccalib320d.lib
opencv_core320d.lib
opencv_datasets320d.lib
opencv_dpm320d.lib
opencv_face320d.lib
opencv_features2d320d.lib
opencv_flann320d.lib
opencv_fuzzy320d.lib
opencv_highgui320d.lib
opencv_imgcodecs320d.lib
opencv_imgproc320d.lib
opencv_line_descriptor320d.lib
opencv_ml320d.lib
opencv_objdetect320d.lib
opencv_optflow320d.lib
opencv_phase_unwrapping320d.lib
opencv_photo320d.lib
opencv_plot320d.lib
opencv_reg320d.lib
opencv_rgbd320d.lib
opencv_saliency320d.lib
opencv_shape320d.lib
opencv_stereo320d.lib
opencv_stitching320d.lib
opencv_structured_light320d.lib
opencv_superres320d.lib
opencv_surface_matching320d.lib
opencv_text320d.lib
opencv_tracking320d.lib
opencv_video320d.lib
opencv_videoio320d.lib
opencv_videostab320d.lib
opencv_xfeatures2d320d.lib
opencv_ximgproc320d.lib
opencv_xobjdetect320d.lib
opencv_xphoto320d.lib
点击应用,确定,然后就大功告成了!!!
release:
opencv_aruco320.lib
opencv_bgsegm320.lib
opencv_calib3d320.lib
opencv_ccalib320.lib
opencv_core320.lib
opencv_datasets320.lib
opencv_dnn320.lib
opencv_dpm320.lib
opencv_face320.lib
opencv_features2d320.lib
opencv_flann320.lib
opencv_fuzzy320.lib
opencv_highgui320.lib
opencv_imgcodecs320.lib
opencv_imgproc320.lib
opencv_line_descriptor320.lib
opencv_ml320.lib
opencv_objdetect320.lib
opencv_optflow320.lib
opencv_photo320.lib
opencv_plot320.lib
opencv_reg320.lib
opencv_rgbd320.lib
opencv_saliency320.lib
opencv_shape320.lib
opencv_stereo320.lib
opencv_stitching320.lib
opencv_structured_light320.lib
opencv_superres320.lib
opencv_surface_matching320.lib
opencv_text320.lib
opencv_tracking320.lib
opencv_ts320.lib
opencv_video320.lib
opencv_videoio320.lib
opencv_videostab320.lib
opencv_xfeatures2d320.lib
opencv_ximgproc320.lib
opencv_xobjdetect320.lib
opencv_xphoto320.lib
在查阅了多位博客关于配置opencv的博文,历经多次,终于将opencv3.2(3.0和3.1同样配置的方法)含扩展部分配置成功。
vs2013配置opencv3.2