C/C++ development, familiar with opencv modules

Table of contents

1. Overview of opencv module

Two, opencv main module

        2.1 Opencv installation path and content

        2.2 opencv module header file description

        2.3 Mature OpenCV main modules

        2.4 Main module of opencv_contrib extension supported by the community

        2.5 References to library files


1. Overview of opencv module

        The main capability of opencv lies in image processing, especially for the processing of two-dimensional image data. Therefore, such as image structure expression, basic drawing ability, image data matrix operation, image transformation, image convolution, image contour search, target recognition, region segmentation, template matching, image filtering, image feature description, etc. Then it is aimed at the application and combination of images in various industries, such as combining with video, camera calibration, how to obtain video or picture data from the camera, how to load known video and capture picture data, etc. For example, the combination with hardware and operating system supports x86, ARM and other hardware, and also supports win, linux, mac and other operating systems.

        With the rapid rise of artificial intelligence, opencv also followed up immediately, supporting machine learning, deep learning, face recognition and other technologies, and combined with practical applications in various industries, for foreign object/defect detection, target recognition and tracking, object classification and counting , Size/distance/position calculation and many other aspects of application to give support.

Two, opencv main module

        2.1 Opencv installation path and content

        After the opencv installation is complete, in its installation directory (for example, the installation directory based on vc2015+cmake source code compilation in this article is D:\workForMy\OpenCVLib\opencv_VC), including the header file include, library file x64/vc14/lib, dynamic library Link key file directories such as x64/vc14/bin:

         Among them, for developers, the most important thing is the include folder, which stores various application modules of opencv, mature opencv and the latest extended opencv_contrib. The support of opencv_contrib is mainly to add the extension module path to support opencv_contrib source code when compiling the source code (see the blog post https://pyfree.blog.csdn.net/article/details/127627204 for details on win10, vc2015+cmake installation and installation of OpenCV) or this Other blog posts in the column (win10, cmake+MinGW or centos7, cmake+g++ install opencv)

-DOPENCV_EXTRA_MODULES_PATH="$myRepo"/opencv_contrib/modules

        2.2 opencv module header file description

        Let’s take a look at the main functional modules of mature opencv. Take win10, cmake+MinGW installation directory as an example. This compilation installation does not add opencv_contrib support, and some minor modules are shielded from compilation, and enter the include\opencv2 directory. , you can see that some header files and folders are included:

         It should be noted that a folder corresponds to an opencv function module, and the hpp header files placed directly under opencv2 are some summarized header file references. For example, opencv.hpp contains all header files that may be used in OpenCV functions. . It is generally not recommended to directly reference the summary header files in the opencv2 directory, because this will slow down the compilation speed, and it is also not conducive to the library link and the software size when the software is packaged and released later. It is generally recommended that if you only use one, such as image processing-related functions, the compilation time consumed by only including opencv2/imgproc/imgproc.hpp will be much less than the compilation time consumed by including opencv.hpp. Similarly, the source file corresponding to the function also exists in the corresponding src folder. For example, the source code functions of the impproc module exist in ..../modules/improc/src/*.cpp.

        Each file directory under the opencv2 directory is the corresponding header file of each function module. These header files are divided into c header files (*.h) and c++ header files (*.hpp). For example, the header files of core function functions:

#include "opencv2/core/core_c.h"    //旧式C风格
#include "opencv2/core/core.hpp"    //新式C++风格

        It is generally recommended that if it is a pure c development project, use c-style header file support, and others use c++ style.

        2.3 Mature OpenCV main modules

        Usually the current version is installed by default, without adding some special settings of module switches, generally the following OpenCV modules will be installed:

         The capabilities of these functional modules are briefly described as follows:

Core:该模块包含OpenCV库的基础结构以及基本操作。

Improc:图像处理模块包含基本的图像转换,包括滤波以及类似的卷积操作。

Highgui:(在OpenCV 3.0以后,分割为imcodecs、videoio以及highgui三部分)这个模块包含可以用来显示图像或者简单的输入的用户交互函数。这可以看作是一个非常轻量级的Windows UI工具包。

Video:该模块包含读取和写视频流的函数。

Calib3d:这个模块包括校准单个、双目以及多个相机的算法实现。

Feature2d:这个模块包含用于检测、描述以及匹配特征点的算法。

Objdectect:这个模块包含检测特定目标,比如人脸或者行人的算法。也可以训练检测器并用来检测其他物体。

Ml:机器学习模块本身是一个非常完备的模块,包含大量的机器学习算法实现并且这些算法都能和OpenCV的数据类型自然交互。

Dnn:深度神经网络。

Flann:Flann的意思是"快速最邻近库"。这个库包含一些你也许不会直接使用的方法,但是其他模块中的函数会调用它在数据集中进行最邻近搜索。

Photo:这是一个相当新的模块,包含计算摄影学的一些函数工具。

Stitching:本模块是一个精巧的图像拼接流程实现。这是库中的新功能,但是,就像Photo模块一样,这个领域未来预计有很大的增长。

        2.4 Main module of opencv_contrib extension supported by the community

        Modules in opencv_contrib, primarily maintained and developed by the community, may have parts not licensed by OpenCV, and may include patent-protected algorithms. When OpenCV releases a new version, some mature modules that are frequently used in opencv_contrib and recognized by the market may be added to the OpenCV ontology. In addition, with the iterative update of the OpenCV version, some old and outdated functional modules will be migrated from the OpenCV ontology to opencv_contrib to retain support for old projects. In the current version, usually the following commonly used modules in opencv_contrib (win10, vc2015+cmake, support opencv_contrib press the following directory):

Face:人脸识别。

Text:文本检测以及识别,基于许多开源的OCR算法。

Rgbd:处理由Kinect或者其他深度传感器(或者简单的由双目匹配得到的)获取的RGB+深度图像。

Bioinspired:一些基于生物学启发的视觉技术。

ximgproc和xphoto:先进的图像处理以及计算摄影学方法。

Tracking:现代目标追踪算法。

        2.5 References to library files

        Generally, if you choose dynamic compilation when installing and compiling, it is best to add the directory where the library is located to the environment variable:

win下通常是:
操作系统\编译器名\bin;操作系统\编译器名\lib
例如:
x64\mingw\bin;x64\mingw\lib
x64\vc14\bin;x64\vc14\lib
win环境变量设置示例如下:
opencv_dir = D:\workForMy\OpenCVLib\opencv_VC\x64\vc14
path = %opencv_dir%/bin;%opencv_dir%/lib;其他环境变量路径

linux下通常是:
/usr/local/lib*
例如:
/usr/local/lib64
Linux环境变量设置示例如下:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64

        The reference of the dynamic library file will refer to the corresponding function module library file according to the functions of those modules called in the program.

头文件引用
INCLUDEDIR 	:= -I"../opencv_MinGW/include"
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>

//库引用
LIBDIR		:= -L"../opencv_MinGW/x64/mingw/bin" -lopencv_core460 -lopencv_highgui460 -lopencv_imgcodecs460

        If you choose to compile statically, it is best to enable BUILD_opencv_world support when compiling:

-DBUILD_opencv_world=ON

        This is for static library references to directly refer to libopencv_world*.a, where * represents the version number.

//头文件引用
INCLUDEDIR 	:= -I"../opencv_MinGW/include"
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>

//静态库引用,分为三部分,opencv总库,第三方依赖库、编译器本身基础依赖库
staticDir   := ../opencv_MinGW/x64/mingw/staticlib/
LIBDIR		:= $(staticDir)/libopencv_world460.a\
			   $(staticDir)/libade.a \
			   $(staticDir)/libIlmImf.a \
			   $(staticDir)/libquirc.a \
			   $(staticDir)/libzlib.a \
			   $(wildcard $(staticDir)/liblib*.a) \
			   -lgdi32 -lComDlg32 -lOleAut32 -lOle32 -luuid 

        The dynamic library reference under linux is similar:

//头文件引用
INCLUDEDIR 	:= -I"/usr/local/include/opencv4" 
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>

//库引用
DLLDIR		:= "/usr/local/lib64"
LIBDIR		:= -L $(DLLDIR) -lopencv_core -lopencv_highgui -lopencv_imgcodecs

 

Guess you like

Origin blog.csdn.net/py8105/article/details/130054018