OpenCV 5.0.0
Open Source Computer Vision
読み込み中...
検索中...
見つかりません
🤖 AIによる機械翻訳(非公式) — これは OpenCV 5.0.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。
Graph 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)
 2値画像から輪郭を検出する。
 
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)
 2値画像内の輪郭とその階層構造を検出する。
 
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(textual ID)は "org.opencv.imgproc.shape.boundingRectVector32F" である
引数
src入力2D点集合。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(textual ID)は "org.opencv.imgproc.shape.boundingRectVector32S" である
引数
src入力2D点集合。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(textual ID)は "org.opencv.imgproc.shape.boundingRectMat" である
  • 2D点の集合が与えられた場合、Mat は2次元であり、2チャンネルの場合は単一の行または列を持つか、シングルチャンネルの場合は2列を持つ必要がある。MatCV_32S または CV_32F のいずれかのビット深度を持つ必要がある
引数
src入力グレースケール画像 CV_8UC1。または Mat に格納された CV_32S または CV_32F の2D点の入力集合。

◆ findContours() [1/2]

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

#include <opencv2/gapi/imgproc.hpp>

これは利便性のために提供されているオーバーロードされたメンバ関数である。上記の関数とは、受け取る引数のみが異なる。

覚え書き
関数のテキストID(textual ID)は "org.opencv.imgproc.shape.findContoursNoOffset" である

◆ findContours() [2/2]

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

#include <opencv2/gapi/imgproc.hpp>

2値画像内の輪郭を検出する。

この関数は、アルゴリズム [267] を用いて二値画像から輪郭を取得する。輪郭は形状解析や物体検出・認識に有用なツールである。OpenCVのサンプルディレクトリにある squares.cpp を参照。

覚え書き
関数のテキストID(textual ID)は "org.opencv.imgproc.shape.findContours" である
引数
src入力グレースケール画像 CV_8UC1。非ゼロのピクセルは1として扱われる。ゼロのピクセルは0のままなので、画像は2値として扱われる。グレースケール画像やカラー画像から2値画像を作成するには、compareinRangethresholdadaptiveThresholdCanny などを使用できる。modeが RETR_CCOMP に等しい場合、入力はラベルの32ビット整数画像 ( CV_32SC1 ) でもよい。RETR_FLOODFILL の場合は CV_32SC1 のみがサポートされる。
mode輪郭の取得モード。RetrievalModes を参照。
method輪郭の近似手法。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(textual 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 method,
const GOpaque< Point > & offset )

#include <opencv2/gapi/imgproc.hpp>

2値画像内の輪郭とその階層構造を検出する。

この関数は、アルゴリズム [267] を用いて二値画像から輪郭を取得し、その階層構造を計算する。輪郭は形状解析や物体検出・認識に有用なツールである。OpenCVのサンプルディレクトリにある squares.cpp を参照。

覚え書き
関数のテキストID(textual ID)は "org.opencv.imgproc.shape.findContoursH" である
引数
src入力グレースケール画像 CV_8UC1。非ゼロのピクセルは1として扱われる。ゼロのピクセルは0のままなので、画像は2値として扱われる。グレースケール画像やカラー画像から2値画像を作成するには、compareinRangethresholdadaptiveThresholdCanny などを使用できる。modeが RETR_CCOMP に等しい場合、入力はラベルの32ビット整数画像 ( CV_32SC1 ) でもよい。RETR_FLOODFILL の場合は CV_32SC1 のみをサポートする。
mode輪郭の取得モード。RetrievalModes を参照。
method輪郭の近似手法。ContourApproximationModes を参照。
offset各輪郭点をシフトする省略可能なオフセット。輪郭を画像のROIから抽出し、画像全体の文脈で解析する場合に有用である。
戻り値
  • 検出された輪郭の GArray。各輪郭は点の GArray として格納される。
  • cv::Vec4i の省略可能な出力 GArray。画像のトポロジーに関する情報を含む。輪郭の数と同じ数の要素を持つ。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(textual 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(textual 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(textual 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)\) を最小化することで2D点集合に直線を当てはめる。ここで \(r_i\) は \(i^{th}\) 番目の点と直線との距離であり、\(\rho(r)\) は距離関数で、次のいずれかである。

  • DIST_L2

    \[\rho (r) = r^2/2 \quad \text{(the simplest and the fastest least-squares method)}\]

  • 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{where} \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{where} \quad C=2.9846\]

  • DIST_HUBER

    \[\rho (r) = \fork{r^2/2}{if \(r < C\)}{C \cdot (r-C/2)}{otherwise} \quad \text{where} \quad C=1.345\]

このアルゴリズムは、重み付き最小二乗法を用いて反復的に直線を当てはめるM推定量 ( http://en.wikipedia.org/wiki/M-estimator ) の手法に基づいている。各反復の後、重み \(w_i\) は \(\rho(r_i)\) に反比例するように調整される。

覚え書き
  • 関数のテキストID(textual ID)は "org.opencv.imgproc.shape.fitLine2DMat" である
  • N次元の点の集合が与えられた場合、Mat は2次元であり、Nチャンネルの場合は単一の行または列を持つか、シングルチャンネルの場合はN列を持つ必要がある。
引数
src可能なコンテナのいずれかに格納された2D点の入力集合: Mat、std::vector<cv::Point2i>、std::vector<cv::Point2f>、std::vector<cv::Point2d>。
distTypeM推定量で使用される距離。DistanceTypes を参照。DIST_USERDIST_C はサポートされていない。
param一部の距離種別における数値パラメータ ( C )。0の場合、最適な値が選択される。
reps半径(座標原点と直線との距離)に対する十分な精度。repsには1.0が適切なデフォルト値である。0の場合、デフォルト値が選択される。
aeps角度に対する十分な精度。aepsには0.01が適切なデフォルト値である。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(textual 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(textual 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(textual 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)\) を最小化することで3D点集合に直線を当てはめる。ここで \(r_i\) は \(i^{th}\) 番目の点と直線との距離であり、\(\rho(r)\) は距離関数で、次のいずれかである。

  • DIST_L2

    \[\rho (r) = r^2/2 \quad \text{(the simplest and the fastest least-squares method)}\]

  • 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{where} \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{where} \quad C=2.9846\]

  • DIST_HUBER

    \[\rho (r) = \fork{r^2/2}{if \(r < C\)}{C \cdot (r-C/2)}{otherwise} \quad \text{where} \quad C=1.345\]

このアルゴリズムは、重み付き最小二乗法を用いて反復的に直線を当てはめるM推定量 ( http://en.wikipedia.org/wiki/M-estimator ) の手法に基づいている。各反復の後、重み \(w_i\) は \(\rho(r_i)\) に反比例するように調整される。

覚え書き
  • 関数のテキストID(textual ID)は "org.opencv.imgproc.shape.fitLine3DMat" である
  • N次元の点の集合が与えられた場合、Mat は2次元であり、Nチャンネルの場合は単一の行または列を持つか、シングルチャンネルの場合はN列を持つ必要がある。
引数
src可能なコンテナのいずれかに格納された3D点の入力集合: Mat、std::vector<cv::Point3i>、std::vector<cv::Point3f>、std::vector<cv::Point3d>。
distTypeM推定量で使用される距離。DistanceTypes を参照。DIST_USERDIST_C はサポートされていない。
param一部の距離種別における数値パラメータ ( C )。0の場合、最適な値が選択される。
reps半径(座標原点と直線との距離)に対する十分な精度。repsには1.0が適切なデフォルト値である。0の場合、デフォルト値が選択される。
aeps角度に対する十分な精度。aepsには0.01が適切なデフォルト値である。0の場合、デフォルト値が選択される。
戻り値
出力される直線パラメータ。6要素のベクトル (Vec6f のような) - (vx, vy, vz, x0, y0, z0)。ここで (vx, vy, vz) は直線に平行な正規化ベクトル、(x0, y0, z0) は直線上の点である。