OpenCV 4.12.0
開源計算機視覺
載入中...
搜尋中...
無匹配項
圖形 API:影像結構分析和形狀描述符

詳細描述

函式

GOpaque< Rectcv::gapi::boundingRect (const GArray< Point2f > &src)
 
GOpaque< Rectcv::gapi::boundingRect (const GArray< Point2i > &src)
 
GOpaque< Rectcv::gapi::boundingRect (const GMat &src)
 計算點集或灰度影像非零畫素的垂直邊界矩形。
 
GArray< GArray< Point > > cv::gapi::findContours (const GMat &src, const RetrievalModes mode, const ContourApproximationModes method)
 
GArray< GArray< Point > > cv::gapi::findContours (const GMat &src, const RetrievalModes mode, const ContourApproximationModes method, const GOpaque< Point > &offset)
 在二值影像中查詢輪廓。
 
std::tuple< GArray< GArray< Point > >, GArray< Vec4i > > cv::gapi::findContoursH (const GMat &src, const RetrievalModes mode, const ContourApproximationModes method)
 
std::tuple< GArray< GArray< Point > >, GArray< Vec4i > > cv::gapi::findContoursH (const GMat &src, const RetrievalModes mode, const ContourApproximationModes method, const GOpaque< Point > &offset)
 在二值影像中查詢輪廓及其層次結構。
 
GOpaque< Vec4fcv::gapi::fitLine2D (const GArray< Point2d > &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 
GOpaque< Vec4fcv::gapi::fitLine2D (const GArray< Point2f > &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 
GOpaque< Vec4fcv::gapi::fitLine2D (const GArray< Point2i > &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 
GOpaque< Vec4fcv::gapi::fitLine2D (const GMat &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 將直線擬合到 2D 點集。
 
GOpaque< Vec6fcv::gapi::fitLine3D (const GArray< Point3d > &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 
GOpaque< Vec6fcv::gapi::fitLine3D (const GArray< Point3f > &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 
GOpaque< Vec6fcv::gapi::fitLine3D (const GArray< Point3i > &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 
GOpaque< Vec6fcv::gapi::fitLine3D (const GMat &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 將直線擬合到 3D 點集。
 

函式文件

◆ boundingRect() 過載 [1/3]

GOpaque< Rect > cv::gapi::boundingRect ( const GArray< Point2f > & src)
Python
cv.gapi.boundingRect(src) -> retval

#include <opencv2/gapi/imgproc.hpp>

這是一個過載成員函式,為方便起見而提供。它與上述函式的區別僅在於其接受的引數不同。

計算點集的垂直邊界矩形。

注意
函式文字ID為 "org.opencv.imgproc.shape.boundingRectVector32F"
引數
src輸入的二維點集,儲存在 std::vector<cv::Point2f> 中。

◆ boundingRect() 過載 [2/3]

GOpaque< Rect > cv::gapi::boundingRect ( const GArray< Point2i > & src)
Python
cv.gapi.boundingRect(src) -> retval

#include <opencv2/gapi/imgproc.hpp>

這是一個過載成員函式,為方便起見而提供。它與上述函式的區別僅在於其接受的引數不同。

計算點集的垂直邊界矩形。

注意
函式文字ID為 "org.opencv.imgproc.shape.boundingRectVector32S"
引數
src輸入的二維點集,儲存在 std::vector<cv::Point2i> 中。

◆ boundingRect() 過載 [3/3]

GOpaque< Rect > cv::gapi::boundingRect ( const GMat & src)
Python
cv.gapi.boundingRect(src) -> retval

#include <opencv2/gapi/imgproc.hpp>

計算點集或灰度影像非零畫素的垂直邊界矩形。

此函式計算並返回指定點集或灰度影像非零畫素的最小垂直邊界矩形。

注意
  • 函式文字ID為 "org.opencv.imgproc.shape.boundingRectMat"
  • 如果給定的是二維點集,則 Mat 應該是二維的,如果包含 2 個通道則應為單行或單列,如果為單通道則應為 2 列。Mat 的深度應為 CV_32SCV_32F
引數
src輸入的灰度影像 CV_8UC1;或儲存在 Mat 中的 CV_32SCV_32F 二維點集。

◆ findContours() 過載 [1/2]

GArray< GArray< Point > > cv::gapi::findContours ( const GMat & src,
const RetrievalModes mode,
const ContourApproximationModes method )

#include <opencv2/gapi/imgproc.hpp>

這是一個過載成員函式,為方便起見而提供。它與上述函式的區別僅在於其接受的引數不同。

注意
函式文字ID為 "org.opencv.imgproc.shape.findContoursNoOffset"

◆ findContours() 過載 [2/2]

GArray< GArray< Point > > cv::gapi::findContours ( const GMat & src,
const RetrievalModes mode,
const ContourApproximationModes 方法,
const GOpaque< Point > & offset )

#include <opencv2/gapi/imgproc.hpp>

在二值影像中查詢輪廓。

該函式使用演算法 [261] 從二值影像中檢索輪廓。輪廓是形狀分析以及物件檢測和識別的有用工具。請參閱 OpenCV 示例目錄中的 squares.cpp。

注意
函式文字ID為 "org.opencv.imgproc.shape.findContours"
引數
src輸入的灰度影像 CV_8UC1。非零畫素被視為 1,零畫素仍為 0,因此影像被視為二值影像。您可以使用 compareinRangethresholdadaptiveThresholdCanny 等函式從灰度影像或彩色影像建立二值影像。如果模式等於 RETR_CCOMP,則輸入也可以是 32 位整數標籤影像 (CV_32SC1)。如果為 RETR_FLOODFILL,則僅支援 CV_32SC1
mode輪廓檢索模式,請參閱 RetrievalModes
方法輪廓近似方法,請參閱 ContourApproximationModes
offset可選的偏移量,每個輪廓點都將按此偏移。這在從影像 ROI 提取輪廓並在整個影像上下文中分析它們時很有用。
返回
檢測到的輪廓的 GArray。每個輪廓都儲存為點的 GArray

◆ findContoursH() 過載 [1/2]

std::tuple< GArray< GArray< Point > >, GArray< Vec4i > > cv::gapi::findContoursH ( const GMat & src,
const RetrievalModes mode,
const ContourApproximationModes method )

#include <opencv2/gapi/imgproc.hpp>

這是一個過載成員函式,為方便起見而提供。它與上述函式的區別僅在於其接受的引數不同。

注意
函式文字ID為 "org.opencv.imgproc.shape.findContoursHNoOffset"

◆ findContoursH() 過載 [2/2]

std::tuple< GArray< GArray< Point > >, GArray< Vec4i > > cv::gapi::findContoursH ( const GMat & src,
const RetrievalModes mode,
const ContourApproximationModes 方法,
const GOpaque< Point > & offset )

#include <opencv2/gapi/imgproc.hpp>

在二值影像中查詢輪廓及其層次結構。

該函式使用演算法 [261] 從二值影像中檢索輪廓並計算它們的層次結構。輪廓是形狀分析以及物件檢測和識別的有用工具。請參閱 OpenCV 示例目錄中的 squares.cpp。

注意
函式文字ID為 "org.opencv.imgproc.shape.findContoursH"
引數
src輸入的灰度影像 CV_8UC1。非零畫素被視為 1,零畫素仍為 0,因此影像被視為二值影像。您可以使用 compareinRangethresholdadaptiveThresholdCanny 等函式從灰度影像或彩色影像建立二值影像。如果模式等於 RETR_CCOMP,則輸入也可以是 32 位整數標籤影像 (CV_32SC1)。如果為 RETR_FLOODFILL,則僅支援 CV_32SC1
mode輪廓檢索模式,請參閱 RetrievalModes
方法輪廓近似方法,請參閱 ContourApproximationModes
offset可選的偏移量,每個輪廓點都將按此偏移。這在從影像 ROI 提取輪廓並在整個影像上下文中分析它們時很有用。
返回
  • 檢測到的輪廓的 GArray。每個輪廓都儲存為點的 GArray
  • 可選輸出 GArray 型別的 cv::Vec4i,包含影像拓撲資訊。它包含與輪廓數量相同的元素。對於每個第 i 個輪廓 contours[i],元素 hierarchy[i][0]、hierarchy[i][1]、hierarchy[i][2] 和 hierarchy[i][3] 分別設定為同一層次級別的下一個和上一個輪廓、第一個子輪廓和父輪廓在 contours 中的基於 0 的索引。如果輪廓 i 沒有下一個、上一個、父級或巢狀輪廓,則 hierarchy[i] 的相應元素將為負值。

◆ fitLine2D() 過載 [1/4]

GOpaque< Vec4f > cv::gapi::fitLine2D ( const GArray< Point2d > & src,
const DistanceTypes distType,
const double param = 0.,
const double reps = 0.,
const double aeps = 0. )

#include <opencv2/gapi/imgproc.hpp>

這是一個過載成員函式,為方便起見而提供。它與上述函式的區別僅在於其接受的引數不同。

注意
函式文字ID為 "org.opencv.imgproc.shape.fitLine2DVector64F"

◆ fitLine2D() 過載 [2/4]

GOpaque< Vec4f > cv::gapi::fitLine2D ( const GArray< Point2f > & src,
const DistanceTypes distType,
const double param = 0.,
const double reps = 0.,
const double aeps = 0. )

#include <opencv2/gapi/imgproc.hpp>

這是一個過載成員函式,為方便起見而提供。它與上述函式的區別僅在於其接受的引數不同。

注意
函式文字ID為 "org.opencv.imgproc.shape.fitLine2DVector32F"

◆ fitLine2D() 過載 [3/4]

GOpaque< Vec4f > cv::gapi::fitLine2D ( const GArray< Point2i > & src,
const DistanceTypes distType,
const double param = 0.,
const double reps = 0.,
const double aeps = 0. )

#include <opencv2/gapi/imgproc.hpp>

這是一個過載成員函式,為方便起見而提供。它與上述函式的區別僅在於其接受的引數不同。

注意
函式文字ID為 "org.opencv.imgproc.shape.fitLine2DVector32S"

◆ fitLine2D() 過載 [4/4]

GOpaque< Vec4f > cv::gapi::fitLine2D ( const GMat & src,
const DistanceTypes distType,
const double param = 0.,
const double reps = 0.,
const double aeps = 0. )

#include <opencv2/gapi/imgproc.hpp>

將直線擬合到 2D 點集。

該函式透過最小化 \(\sum_i \rho(r_i)\) 將直線擬合到二維點集,其中 \(r_i\) 是第 \(i\) 個點與直線之間的距離,而 \(\rho(r)\) 是距離函式,可以是以下之一:

  • DIST_L2

    \[\rho (r) = r^2/2 \quad \text{(最簡單、最快的最小二乘法)}\]

  • DIST_L1

    \[\rho (r) = r\]

  • DIST_L12

    \[\rho (r) = 2 \cdot ( \sqrt{1 + \frac{r^2}{2}} - 1)\]

  • DIST_FAIR

    \[\rho \left (r \right ) = C^2 \cdot \left ( \frac{r}{C} - \log{\left(1 + \frac{r}{C}\right)} \right ) \quad \text{其中} \quad C=1.3998\]

  • DIST_WELSCH

    \[\rho \left (r \right ) = \frac{C^2}{2} \cdot \left ( 1 - \exp{\left(-\left(\frac{r}{C}\right)^2\right)} \right ) \quad \text{其中} \quad C=2.9846\]

  • DIST_HUBER

    \[\rho (r) = \fork{r^2/2}{如果 \(r < C\)}{C \cdot (r-C/2)}{否則} \quad \text{其中} \quad C=1.345\]

該演算法基於 M 估計器 (http://en.wikipedia.org/wiki/M-estimator) 技術,該技術使用加權最小二乘演算法迭代地擬合直線。每次迭代後,權重 \(w_i\) 會被調整為與 \(\rho(r_i)\) 成反比。

注意
  • 函式文字ID為 "org.opencv.imgproc.shape.fitLine2DMat"
  • 如果給定的是 N 維點集,則 Mat 應該是二維的,如果包含 N 個通道則應為單行或單列,如果為單通道則應為 N 列。
引數
src輸入的二維點集,儲存在以下可能的容器之一中:Mat、std::vector<cv::Point2i>、std::vector<cv::Point2f>、std::vector<cv::Point2d>。
distTypeM 估計器使用的距離型別,請參閱 DistanceTypesDIST_USERDIST_C 不受支援。
param某些距離型別的數值引數 (C)。如果為 0,則選擇一個最優值。
reps半徑(座標原點與直線之間的距離)的足夠精度。1.0 是 reps 的一個很好的預設值。如果為 0,則選擇一個預設值。
aeps角度的足夠精度。0.01 是 aeps 的一個很好的預設值。如果為 0,則選擇一個預設值。
返回
輸出直線引數:一個包含 4 個元素(如 Vec4f)的向量 - (vx, vy, x0, y0),其中 (vx, vy) 是與直線共線的歸一化向量,(x0, y0) 是直線上的一個點。

◆ fitLine3D() 過載 [1/4]

GOpaque< Vec6f > cv::gapi::fitLine3D ( const GArray< Point3d > & src,
const DistanceTypes distType,
const double param = 0.,
const double reps = 0.,
const double aeps = 0. )

#include <opencv2/gapi/imgproc.hpp>

這是一個過載成員函式,為方便起見而提供。它與上述函式的區別僅在於其接受的引數不同。

注意
函式文字ID為 "org.opencv.imgproc.shape.fitLine3DVector64F"

◆ fitLine3D() 過載 [2/4]

GOpaque< Vec6f > cv::gapi::fitLine3D ( const GArray< Point3f > & src,
const DistanceTypes distType,
const double param = 0.,
const double reps = 0.,
const double aeps = 0. )

#include <opencv2/gapi/imgproc.hpp>

這是一個過載成員函式,為方便起見而提供。它與上述函式的區別僅在於其接受的引數不同。

注意
函式文字ID為 "org.opencv.imgproc.shape.fitLine3DVector32F"

◆ fitLine3D() 過載 [3/4]

GOpaque< Vec6f > cv::gapi::fitLine3D ( const GArray< Point3i > & src,
const DistanceTypes distType,
const double param = 0.,
const double reps = 0.,
const double aeps = 0. )

#include <opencv2/gapi/imgproc.hpp>

這是一個過載成員函式,為方便起見而提供。它與上述函式的區別僅在於其接受的引數不同。

注意
函式文字ID為 "org.opencv.imgproc.shape.fitLine3DVector32S"

◆ fitLine3D() 過載 [4/4]

GOpaque< Vec6f > cv::gapi::fitLine3D ( const GMat & src,
const DistanceTypes distType,
const double param = 0.,
const double reps = 0.,
const double aeps = 0. )

#include <opencv2/gapi/imgproc.hpp>

將直線擬合到 3D 點集。

該函式透過最小化 \(\sum_i \rho(r_i)\) 將直線擬合到三維點集,其中 \(r_i\) 是第 \(i\) 個點與直線之間的距離,而 \(\rho(r)\) 是距離函式,可以是以下之一:

  • DIST_L2

    \[\rho (r) = r^2/2 \quad \text{(最簡單、最快的最小二乘法)}\]

  • DIST_L1

    \[\rho (r) = r\]

  • DIST_L12

    \[\rho (r) = 2 \cdot ( \sqrt{1 + \frac{r^2}{2}} - 1)\]

  • DIST_FAIR

    \[\rho \left (r \right ) = C^2 \cdot \left ( \frac{r}{C} - \log{\left(1 + \frac{r}{C}\right)} \right ) \quad \text{其中} \quad C=1.3998\]

  • DIST_WELSCH

    \[\rho \left (r \right ) = \frac{C^2}{2} \cdot \left ( 1 - \exp{\left(-\left(\frac{r}{C}\right)^2\right)} \right ) \quad \text{其中} \quad C=2.9846\]

  • DIST_HUBER

    \[\rho (r) = \fork{r^2/2}{如果 \(r < C\)}{C \cdot (r-C/2)}{否則} \quad \text{其中} \quad C=1.345\]

該演算法基於 M 估計器 (http://en.wikipedia.org/wiki/M-estimator) 技術,該技術使用加權最小二乘演算法迭代地擬合直線。每次迭代後,權重 \(w_i\) 會被調整為與 \(\rho(r_i)\) 成反比。

注意
  • 函式文字ID為 "org.opencv.imgproc.shape.fitLine3DMat"
  • 如果給定的是 N 維點集,則 Mat 應該是二維的,如果包含 N 個通道則應為單行或單列,如果為單通道則應為 N 列。
引數
src輸入的三維點集,儲存在以下可能的容器之一中:Mat、std::vector<cv::Point3i>、std::vector<cv::Point3f>、std::vector<cv::Point3d>。
distTypeM 估計器使用的距離型別,請參閱 DistanceTypesDIST_USERDIST_C 不受支援。
param某些距離型別的數值引數 (C)。如果為 0,則選擇一個最優值。
reps半徑(座標原點與直線之間的距離)的足夠精度。1.0 是 reps 的一個很好的預設值。如果為 0,則選擇一個預設值。
aeps角度的足夠精度。0.01 是 aeps 的一個很好的預設值。如果為 0,則選擇一個預設值。
返回
輸出直線引數:一個包含 6 個元素(如 Vec6f)的向量 - (vx, vy, vz, x0, y0, z0),其中 (vx, vy, vz) 是與直線共線的歸一化向量,(x0, y0, z0) 是直線上的一個點。