1. 程式人生 > >Opencv各個模組功能詳細簡介

Opencv各個模組功能詳細簡介

3.2版本的模組說明:Opencv3.2模組

首先開啟opencv_modules.hpp檔案,可以看到對於各個功能模組的定義如下: 
//功能模組和3.1一樣…

 
  1. /*

  2. * ** File generated automatically, do not modify **

  3. *

  4. * This file defines the list of modules available in current build configuration

  5. *

  6. *

  7. */

  8.  
  9. #define HAVE_OPENCV_CALIB3D

  10. #define HAVE_OPENCV_CORE

  11. #define HAVE_OPENCV_FEATURES2D

  12. #define HAVE_OPENCV_FLANN

  13. #define HAVE_OPENCV_HIGHGUI

  14. #define HAVE_OPENCV_IMGCODECS

  15. #define HAVE_OPENCV_IMGPROC

  16. #define HAVE_OPENCV_ML

  17. #define HAVE_OPENCV_OBJDETECT

  18. #define HAVE_OPENCV_PHOTO

  19. #define HAVE_OPENCV_SHAPE

  20. #define HAVE_OPENCV_STITCHING

  21. #define HAVE_OPENCV_SUPERRES

  22. #define HAVE_OPENCV_VIDEO

  23. #define HAVE_OPENCV_VIDEOIO

  24. #define HAVE_OPENCV_VIDEOSTAB

  25. #define HAVE_OPENCV_WORLD

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

接著按照上述功能模組對照官方說明進行介紹。


3D相關CALIB3D

全稱是Camera Calibration and 3D Reconstruction,也就是所謂的攝像機標定與三維重建。 
包括: 
1.基本多視角幾何演算法 
2.單立體攝像機標定 
3.物體位姿估計 
4.三維重建要素

calib3d - basic multiple-view geometry algorithms, single and stereo camera calibration, object pose estimation, stereo correspondence algorithms, and elements of 3D reconstruction.
  • 1
  • 1

最基礎部分CORE

定義了Opencv最為基礎的資料結構,是一個內容非常詳實與緊湊的模組。 
包括了: 
1.最基礎的結構體 
Basic Structures 
Basic C Structures and Operations 
2.動態結構(Opencv1用得多,新版的不需要關注這些,利用std::vector或其他更高階的結構即可) 
Dynamic Structures 
3.陣列操作,包括了abs,absdiff,add,addWeighted,bitwise_and….等等一些列的陣列操作運算 
詳情見地址:官方說明文件//有空或許會把這個寫一篇部落格…… 
Operations on Arrays 
4.繪畫的功能,畫點,線,圓,橢圓,方框等等…… 
Drawing Functions 
5.XML/YAML檔案進行儲存或呼叫Opencv的各種資料結構,我之前有篇部落格進行表情識別的時候就利用了XML進行特徵的提取,還是非常方便的,XML的使用案例 
XML/YAML Persistence 
XML/YAML Persistence (C API) 
6.聚類:K-Mean聚類以及分割的API 
Clustering 
7.輔助功能與系統函式和巨集 
Utility and System Functions and Macros 
8.OpenGL互動相關 
OpenGL interoperability 
首先想進行互動需要自己編譯Opencv把OPENGL的狀態設定為ON。2.4版本的只支援基於windows或linux的win32,GTK,Qt的組合……安卓和macOS的不支援… 
更為詳細的資訊見連結: 
OpenCV+OpenGL2.4版本

OpenCV+OpenGL3.2版本

—————————–3.2與2.4相比增添的內容: 
1.Intel IPP Asynchronous C/C++ Converters 
2.Optimization Algorithms 
3.DirectX interoperability 
4.Eigen support 
5.OpenCL support:僅限Linux使用 
6.Intel VA-API/OpenCL (CL-VA) interoperability 
7.Hardware Acceleration Layer

core - a compact module defining basic data structures, including the dense multi-dimensional array Mat and basic functions used by all other modules.
  • 1
  • 1

2D特徵FEATURES2D

顯著的特徵描述符,描述符匹配器和探測器,包括以下幾塊內容:

1.特徵的檢測以及描述:包括Fast演算法,MSER,ORB,BRISK,FREAK 
Feature Detection and Description 
2.特徵檢測器的介面 
Common Interfaces of Feature Detectors 
3.描述符提取器的介面 
Common Interfaces of Descriptor Extractors 
4.描述符匹配器的介面 
Common Interfaces of Descriptor Matchers 
5.通用描述符匹配器的介面 
Common Interfaces of Generic Descriptor Matchers 
6.關鍵點以及匹配的繪製函式 
Drawing Function of Keypoints and Matches 
7.物體分類:這是基於local 2D features的物體分類,有BOW訓練器以及BOW分類器兩個模組 
Object Categorization

—————3.2裡本質一樣,分類看上去更為清爽一點: 
Feature Detection and Description

Descriptor Matchers

Drawing Function of Keypoints and Matches

Object Categorization


近鄰搜尋FLANN

FLANN庫全稱是Fast Library for Approximate Nearest Neighbors,它是目前最完整的(近似)最近鄰開源庫。不但實現了一系列查詢演算法,還包含了一種自動選取最快演算法的機制。 摘自:FLANN使用說明 
主要分為: 
1.快速近似最近鄰搜尋FLANN 
2.聚類Clustering


高層級的互動HIGHGUI

High-level GUI and Media I/O 高層級的使用者互動以及媒體的IO介面,主要包括以下幾個方面: 
1.使用者互動:包括顯示圖片,視窗的操作,滑鼠的操作等等。 
2.讀寫圖片或者視訊:顧名思義就是對於圖片或者視訊的一些列操作。 
3.Qt新功能://這個之後一定要試試,使用說明地址或者Opencv3.2的使用說明 
結合Qt可以弄成類似於MFC的有按鈕等等功能的介面,大致如下: 
這裡寫圖片描述

—————–3.2與2.4相比在highgui多了OpenGL的支援模組,詳細功能函式如下:

 
  1. void cv::imshow (const String &winname, const ogl::Texture2D &tex)

  2. Displays OpenGL 2D texture in the specified window. More...

  3.  
  4. void cv::setOpenGlContext (const String &winname)

  5. Sets the specified window as current OpenGL context. More...

  6.  
  7. void cv::setOpenGlDrawCallback (const String &winname, OpenGlDrawCallback onOpenGlDraw, void *userdata=0)

  8. Sets a callback function to be called to draw on top of displayed image. More...

  9.  
  10. void cv::updateWindow (const String &winname)

  11. Force window to redraw its context and call draw callback ( See cv::setOpenGlDrawCallback ).

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

圖片的讀寫IMGCODECS

用於圖片的讀寫。//2.4裡沒有這塊

OpenCV3開始圖片、視訊編解碼從highgui模組分離出來,組成了imgcodecs和videoio。Linux環境下需要注意一下,其他沒啥。


圖片的處理IMGPROC

1.影象濾波Image Filtering:線性和非線性,Sobel,Smooth等等一些列實用的功能函式

詳細介紹如下(如果感興趣的話):

Functions and classes described in this section are used to perform various linear or non-linear filtering operations on 2D images (represented as Mat’s). It means that for each pixel location (x,y) in the source image (normally, rectangular), its neighborhood is considered and used to compute the response. In case of a linear filter, it is a weighted sum of pixel values. In case of morphological operations, it is the minimum or maximum values, and so on. The computed response is stored in the destination image at the same location (x,y). It means that the output image will be of the same size as the input image. Normally, the functions support multi-channel arrays, in which case every channel is processed independently. Therefore, the output image will also have the same number of channels as the input one. 
Another common feature of the functions and classes described in this section is that, unlike simple arithmetic functions, they need to extrapolate values of some non-existing pixels. For example, if you want to smooth an image using a Gaussian 3×3 filter, then, when processing the left-most pixels in each row, you need pixels to the left of them, that is, outside of the image. You can let these pixels be the same as the left-most image pixels (“replicated border” extrapolation method), or assume that all the non-existing pixels are zeros (“constant border” extrapolation method), and so on. OpenCV enables you to specify the extrapolation method. For details, see cv::BorderTypes

2.影象的幾何變換Geometric Image Transformations: 
這一部分提供2D影象的很多幾何變換操作,例如非常實用的Resize等等。

3.各種圖片形式的轉換Miscellaneous Image Transformations: 
提供threshold,cvtColor等等12個功能函式

4.直方圖Histograms 
提供便於計算的一些介面

5.結構分析和形狀描述Structural Analysis and Shape Descriptors: 
計算所有多邊形或者柵格化形狀的特證矩moment,例如可以提取下圖的手的凸陷部分://看著非常實用的感覺 
這裡寫圖片描述

6.動作分析以及物體追蹤Motion Analysis and Object Tracking: 
顧名思義……

7.特徵檢測Feature Detection 
(找邊界)canny 
(找角)cornerEigenValsAndVecs,cornerHarris,cornerMinEigenVal,cornerSubPix,(預處理)preCornerDetect 
goodFeaturesToTrack 
(找圓)HoughCircles 
(找線)HoughLines,HoughLinesP

8.物體檢測Object Detection 
就是模板匹配

——–3.2與2.4相比增添了以下內容: 
1.Drawing Functions繪畫的功能: 
最實用的應該就是透明背景了吧,通過Scalar增加alpha位,之前所有的畫圓,方,點線面的函式都可以直接呼叫cv::某個函式()在顏色位加上最後一位來實現半透明的效果。

Scalar(blue_component,green_component,red_component[,alpha_component]) 
  • 1
  • 1

2.給灰度圖重新上色ColorMaps in OpenCV 
功能函式為:void cv::applyColorMap (InputArray src, OutputArray dst, int colormap) 
附上顏色對照表

這裡寫圖片描述

3.平面細分Planar Subdivision 
cv::Subdiv2D 
用於三維定位等等… 
平面細分 
4.C API 
5.Hardware Acceleration Layer


機器學習ML

Machine Learning機器學習模組,基本就是統計學上回歸,分類以及聚類的,大致分為以下幾個部分: 
1.統計模型Statistical Models 
2.一般貝葉斯分類器Normal Bayes Classifier 
3.K-近鄰K-Nearest Neighbors 
4.支援向量機SVM Support Vector Machines:之前嘗試過的案例:SVM案例 
5.決策樹Decision Trees 
6.級聯分類器Boosting 
7.梯度樹Gradient Boosted Trees 
8.隨機樹Random Trees 
9.超隨機樹Extremely randomized trees 
10.期望最大化Expectation Maximization 
11.神經網路Neural Networks 
12.機器學習資料的形式相關MLData

如何訓練以及使用見地址:機器學習官方說明 
————-3.2與2.4相比新增內容 
1.Logistic Regression:類似於SVM也是一種多分類器


物體檢測OBJDETECT

物體檢測 
Opencv2.4包含Cascade Classification(級聯分類)和Latent SVM這兩個部分 
Opencv3.2所採用的方法為 
Haar Feature-based Cascade Classifier for Object Detection


影象降噪克隆與NPR渲染PHOTO

也就是 Computational Photography,Opencv2.4包括以下兩個部分: 
1.影象修復Inpainting

void inpaint(InputArray src, InputArray inpaintMask, OutputArray dst, double inpaintRadius, int flags)
  • 1
  • 1

2.影象降噪Denoising

———–Opencv3.2模組 
1.降噪Denoising相比於2.4功能函式更多了 
2.高範圍動態成像HDR imaging利用HDR演算法,有一系列相關的演算法函式……2.4裡並沒有 
3.無縫克隆Seamless Cloning 
如圖,強大一覽無餘,圖片摘自vsooda的部落格 
這裡寫圖片描述 
4.非真實感渲染Non-Photorealistic Rendering 
看名字很玄乎……大概動畫裡用得很多,把一個圖片渲染得不像真的,如圖所示,左側為一般渲染,右側為NPR渲染(摘自維基百科) 
這裡寫圖片描述 
5.C API


形狀的匹配以及距離計算SHAPE

Shape Distance and Matching,形狀的距離以及匹配 
//對這部分了解不是很多,只能形而上學地複製過來了 
Opencv3特有的部分,Opencv2.4並沒有… 
1. AffineTransformer仿射變換演算法的包裝類 
2. HistogramCostExtractor 
3. HausdorffDistanceExtractor 
4. ShapeContextDistanceExtractor 
5. ThinPlateSplineShapeTransformer


影象拼接STITCHING

影象拼接模組,流程如下,可以去掉或者單獨使用其中某些模組。 
這裡寫圖片描述

主要包括以下內容: 
1.拼接管道Stitching Pipeline 
2.特徵點提取以及圖片匹配Features Finding and Images Matching 
3.旋轉估計Rotation Estimation 
4.自動校準Autocalibration 
5.圖片傾斜旋轉相關的包Images Warping 
6.縫隙估計Seam Estimation 
7.曝光補償Exposure Compensation 
8.圖片混合Image Blenders


超解析度SUPERRES

Super Resolution,包含了一系列的超解析度問題的處理方法 
//對這邊毫無瞭解,只能先形而上學……


視訊分析VIDEO

Video Analysis視訊分析,包括以下兩塊內容: 
1.動作分析Motion Analysis 
2.物體追蹤Object Tracking


視訊讀寫VIDEOIO

OpenCV3特有的僅用來讀寫視訊的模組


視訊穩定系VIDEOSTAB

Video Stabilization、視訊穩定模組包含一組可以用來解決視訊穩定問題的函式和類。2.4基本沒提及,3.2裡內容比較詳實。包括以下兩個內容: 
1.全域性運動估計Global Motion Estimation 
包括一些列功能和類用以進行兩張圖或者兩個點雲陣的全域性動作估計。功能函式都被封裝成了類。 
2.快速步進法Fast Marching Method


打包WORLD

終於到最後一個了,這是Opencv3特有的,把所有東西打包在一個dll裡,配置環境的時候很方便,具體工程實際就要分情況了。

最後放上Opencv3.2以及Opencv2.4模組的對比圖方便呼叫: 
這裡寫圖片描述 
其中Opencv2.4特有的幾個模組功能說明如下: 
//參考了易術軍的部落格 
OPENCV_CONTRIB:也就是Contributed/Experimental Stuf的縮寫, 該模組包含了一些最近新增的不太穩定的可選功能,不用去多管。2.4.8裡的這個模組有新型人臉識別,立體匹配,人工視網膜模型等技術。 
OPENCV_GPU:運用GPU加速的計算機視覺模組 
OPENCV_LEGACY:一些已經廢棄的程式碼庫,保留下來作為向下相容,3裡以及全部刪除。 
OPENCV_NONFREE: 也就是一些具有專利的演算法模組 ,包含特徵檢測和GPU相關的內容,在3裡刪去了。 
OPENCV_OCL :即OpenCL-accelerated Computer Vision,運用OpenCL加速的計算機視覺元件模組,在3裡整個併入了Core. 
OPENCV_TS:測試用。