OpenCV + OpenCV Contrib安装教程(windows)

一、OpenCV Contrib模块简介

OpenCV Contrib是OpenCV的扩展模块,包含了许多最新的以及可能还没有正式发布有待进一步完善的算法,可以理解为是OpenCV的扩展包,在OpenCV 3.0以后,SIFT、SURF等特征算法也放到了Contrib库中了,我第1次安装Contrib,是因为想要使用FLD直线检测器。

二、本文介绍的安装环境

Windows 10  +  vs2017 x64  + OpenCV3.4.3  +  OpenCV Contrib3.4.3  +  Cmake

三、安装环境下载

默认已经安装好操作系统和Visual Studio

  1. OpenCV 3.4.3 下载链接1 下载链接2 注意:下载windowsa安装包就可以了,不需要下载源码,因为安装后的目录中包含源码(当然也可以直接下载源码);
  2. OpenCV Contrib3.4.3  下载链接  注意:一定要下载与OpenCV相同版本的,否则编译时会出现错误;
  3. Cmake 下载链接 下载一个最新版本的windows安装包即可。

四、安装步骤

1、将OpenCV 3.4.3安装在windows系统中;

OpenCV + OpenCV Contrib安装教程(windows)_第1张图片

2、在OpenCV 3.4.3的安装目录中新建目录new_build,用于存放新编译的文件;然后将OpenCV Contrib3.4.3解压到OpenCV 3.4.3的安装目录中;

OpenCV + OpenCV Contrib安装教程(windows)_第2张图片

3、打开安装后的Cmake,在where is the source code中选择openCV的源代码目录:D:\opencv3.4.3\opencv\sources;在where to build the binaries中选择编译后文件存放的目录:D:\opencv3.4.3\opencv\new_build(这里选择第2步中建立的new_build目录);

OpenCV + OpenCV Contrib安装教程(windows)_第3张图片

4、点击configure,第1次使用会弹出对话框,选择对应的vs版本即可,其他的不用管。我的是vs2017 64位,所以我选择的是vs2017 Win64,然后点击确认,程序开始运行,运行完成后会在最下方显示configuration done;

5、在cmake搜索框中搜索OPENCV_EXTRA_MODULES_PATH,将其值选择为opencv_contrib目录中的modules目录,我的是D:\opencv3.4.3\opencv\opencv_contrib-3.4.3\modules;最后再一次点击configure,成功之后依然会在最下边显示configuration done;这时你会看到所有的红色部分都变成白色;

OpenCV + OpenCV Contrib安装教程(windows)_第4张图片

注意:如果这一步发生了错误,查看下是什么原因;大部分错误原因是opencv版本与opencv contrib版本不相同导致。

6、点击“Generate”,生成;

7、在new_build目录中可以看到OpenCV工程,用vs2017打开OpenCV.sln;

OpenCV + OpenCV Contrib安装教程(windows)_第5张图片

8、编译生成Debug库和Release库(选择编译的平台信息(Debug / Release x64));

9、在解决方案中选中工程,右键选择重新生成解决方案(可能会有几个库生成失败,如果这几个库不是你需要的,就忽略它);

OpenCV + OpenCV Contrib安装教程(windows)_第6张图片

10、在CMakeTargets中的INSTALL,然后右键选择“仅限于项目”-->“仅生成INSTALL”;

OpenCV + OpenCV Contrib安装教程(windows)_第7张图片

11、完成编译后,可在切换至Release模式下,同样的操作再来一次。此时,install目录包含了我们需要的头文件、库文件等;

OpenCV + OpenCV Contrib安装教程(windows)_第8张图片

12、在vs2017项目中配置编译后的OpenCV

(1)将D:\opencv3.4.3\opencv\new_build\install\x64\vc15\bin 添加至系统环境变量Path中(可能需要重启电脑使之生效);

(2)Debug模式

包含目录

D:\opencv3.4.3\opencv\new_build\install\include;D:\opencv3.4.3\opencv\new_build\install\include\opencv;D:\opencv3.4.3\opencv\new_build\install\include\opencv2;$(IncludePath)

 

库目录

D:\opencv3.4.3\opencv\new_build\install\x64\vc15\lib;$(LibraryPath)

 

附加依赖项(每个版本中可能会有所不同,最好是使用之前仔细盘查一遍)

opencv_aruco343d.lib

opencv_bgsegm343d.lib

opencv_bioinspired343d.lib

opencv_calib3d343d.lib

opencv_ccalib343d.lib

opencv_core343d.lib

opencv_datasets343d.lib

opencv_dnn_objdetect343d.lib

opencv_dnn343d.lib

opencv_dpm343d.lib

opencv_face343d.lib

opencv_features2d343d.lib

opencv_flann343d.lib

opencv_fuzzy343d.lib

opencv_hfs343d.lib

opencv_highgui343d.lib

opencv_img_hash343d.lib

opencv_imgcodecs343d.lib

opencv_imgproc343d.lib

opencv_line_descriptor343d.lib

opencv_ml343d.lib

opencv_objdetect343d.lib

opencv_optflow343d.lib

opencv_phase_unwrapping343d.lib

opencv_photo343d.lib

opencv_plot343d.lib

opencv_reg343d.lib

opencv_rgbd343d.lib

opencv_saliency343d.lib

opencv_shape343d.lib

opencv_stereo343d.lib

opencv_structured_light343d.lib

opencv_superres343d.lib

opencv_surface_matching343d.lib

opencv_text343d.lib

opencv_tracking343d.lib

opencv_video343d.lib

opencv_videoio343d.lib

opencv_videostab343d.lib

opencv_ximgproc343d.lib

opencv_xobjdetect343d.lib

opencv_xphoto343d.lib

(3)Release模式

包含目录

D:\opencv3.4.3\opencv\new_build\install\include;D:\opencv3.4.3\opencv\new_build\install\include\opencv;D:\opencv3.4.3\opencv\new_build\install\include\opencv2;$(IncludePath)

 

库目录

D:\opencv3.4.3\opencv\new_build\install\x64\vc15\lib;$(LibraryPath)

 

附加依赖项

opencv_aruco343.lib

opencv_bgsegm343.lib

opencv_bioinspired343.lib

opencv_calib3d343.lib

opencv_ccalib343.lib

opencv_core343.lib

opencv_datasets343.lib

opencv_dnn_objdetect343.lib

opencv_dnn343.lib

opencv_dpm343.lib

opencv_face343.lib

opencv_features2d343.lib

opencv_flann343.lib

opencv_fuzzy343.lib

opencv_hfs343.lib

opencv_highgui343.lib

opencv_img_hash343.lib

opencv_imgcodecs343.lib

opencv_imgproc343.lib

opencv_line_descriptor343.lib

opencv_ml343.lib

opencv_objdetect343.lib

opencv_optflow343.lib

opencv_phase_unwrapping343.lib

opencv_photo343.lib

opencv_plot343.lib

opencv_reg343.lib

opencv_rgbd343.lib

opencv_saliency343.lib

opencv_shape343.lib

opencv_stereo343.lib

opencv_structured_light343.lib

opencv_superres343.lib

opencv_surface_matching343.lib

opencv_text343.lib

opencv_tracking343.lib

opencv_video343.lib

opencv_videoio343.lib

opencv_videostab343.lib

opencv_ximgproc343.lib

opencv_xobjdetect343.lib

opencv_xphoto343.lib

(4)接下来就可以在项目中正常使用它了;

最后

增加OpenCV Contrib模块的OpenCV像是做了升级,重新编译后的Opencv既可以使用正常的接口,也可以使用Contrib模块中的接口。

正常使用时,只需要install(D:\opencv3.4.3\opencv\new_build\install)目录就可以了,其他的内容就可以删除了。

你可能感兴趣的:(图像处理--Opencv,OpenCV,Contrib,Contrib安装)