赞
踩
1.首先下载opencv_contrib源码
2.下载cmake-gui工具:http://www.cmake.org/cmake/resources/software.html
3.先编译opencv
4.第一次编译完成之后,我们需要将额外的opencv_contrib加到工程中进行第二次编译,在配置表中找到“OPENCV_EXTRA_MODULES_PATH”,设置其参数值为open_contrib源码包中的modles目录
先点配置,再点生成
Tips:有时opencv_ffmpeg.dll这个下载不下来,打开build目录下CMakeDownloadLog.txt,找到下载地址,放到浏览器手动下载,然后把下载的dll拷贝到
opencv\newcontribBuild\3rdparty\ffmpeg目录下,再进行编译就不会报错了。
还有boostdesc_bgm.i、boostdesc_bgm_hd.i、boostdesc_bgm_bi.i、boostdesc_bgm.i等文件下载不下来,解决方法同上,手动在浏览器打开看到源码,在下载的contrib里(不是生成的那个)opencv\opencv_contrib-3.4.2\modules\xfeatures2d下手动建立这四个文件,然后把源码复制进去就行
编译完成后,我们在资源管理器下查看上面设置的文件输出目录,发现目录下多出了很多文件,其实就是OpenCV.sln工程文件:
5.打开sln文件,先要选择生成项目
生成完之后
最后会有以下文件
6.打开VS属性管理器
1.VC++目录–>包含目录,添加:
D:\installFile\opencv\contribBuild\install\include
D:\installFile\opencv\contribBuild\install\include\opencv2
D:\installFile\opencv\contribBuild\install\include\opencv
2.VC++目录–>库目录,添加:
D:\installFile\opencv\contribBuild\install\x64\vc15\lib
3.链接器–>输入–>附加依赖项,添加: (下面添加的debug的版本,注意添加的库与编译选项要一致,需要注意debug比release的文件名多了个d)
opencv_aruco342d.lib
opencv_bgsegm342d.lib
opencv_bioinspired342d.lib
opencv_calib3d342d.lib
opencv_ccalib342d.lib
opencv_core342d.lib
opencv_datasets342d.lib
opencv_dnn342d.lib
opencv_dnn_objdetect342d.lib
opencv_dpm342d.lib
opencv_face342d.lib
opencv_features2d342d.lib
opencv_flann342d.lib
opencv_fuzzy342d.lib
opencv_hfs342d.lib
opencv_highgui342d.lib
opencv_imgcodecs342d.lib
opencv_imgproc342d.lib
opencv_img_hash342d.lib
opencv_line_descriptor342d.lib
opencv_ml342d.lib
opencv_objdetect342d.lib
opencv_optflow342d.lib
opencv_phase_unwrapping342d.lib
opencv_photo342d.lib
opencv_plot342d.lib
opencv_reg342d.lib
opencv_rgbd342d.lib
opencv_saliency342d.lib
opencv_shape342d.lib
opencv_stereo342d.lib
opencv_stitching342d.lib
opencv_structured_light342d.lib
opencv_superres342d.lib
opencv_surface_matching342d.lib
opencv_text342d.lib
opencv_tracking342d.lib
opencv_video342d.lib
opencv_videoio342d.lib
opencv_videostab342d.lib
opencv_xfeatures2d342d.lib
opencv_ximgproc342d.lib
opencv_xobjdetect342d.lib
opencv_xphoto342d.lib
4.添加环境变量
D:\installFile\opencv\contribBuild\install\x64\vc15\bin
注:有时需要重启电脑环境变量才会生效
参考博客:
https://www.cnblogs.com/jliangqiu2016/p/5597501.html
https://blog.csdn.net/asmartkiller/article/details/89314622
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。