编写日期:2021年1月13日
目录
一、 概述
1. 运行平台
2. 什么是OpenCV_contrib?
二、 下载和安装OpenCV和OpenCV_contrib
1. 下载OpenCV和OpenCV_contrib的源代码
2. 使用CMake编译包含contrib模块的OpenCV
3. 使用Visual Studio完成编译并安装OpenCV
4. 配置环境变量
三、 新建测试工程
四、 参考
一、 概述
1. 运行平台
Visual Studio 2019,包含Visual C++ 16
OpenCV 4.5.1
目前最新的OpenCV_contrib
2. 什么是OpenCV_contrib?
OpenCV分为两大模块:OpenCV和OpenCV_contrib。
以下是【opencv_contrib】项目的官方GitHub页面上的介绍:
This repository is intended for the development of so-called "extra" modules, contributed functionality. New modules quite often do not have stable API, and they are not well-tested. Thus, they shouldn't be released as a part of official OpenCV distribution, since the library maintains binary compatibility, and tries to provide decent performance and stability.
So, all the new modules should be developed separately, and published in the opencv_contrib repository at first. Later, when the module matures and gains popularity, it is moved to the central OpenCV repository, and the development team provides production-quality support for this module.
OpenCV为了保证项目的整体软件质量,将一些较新的,稳定性尚还有所不足的模块不并入OpenCV主工程,而是单独设立一个独立的【opencv_contrib】库供有需要的人使用。
在OpenCV官网下载的用于傻瓜式安装的.exe自解压文件不包含opencv_contrib库中的内容。如果需要使用OpenCV_contrib当中的功能,就必须分别下载OpenCV和OpenCV_contrib的源代码,再通过CMake进行源代码编译。
二、 下载和安装OpenCV和OpenCV_contrib
1. 下载OpenCV和OpenCV_contrib的源代码
这里使用的是OpenCV 4.5.1:https://opencv.org/releases/
(注:当然也可以从OpenCV的GitHub页面下载最新的源代码,不过并不推荐这样做)
OpenCV_contrib:https://github.com/opencv/opencv_contrib