OpenCV  4.5.1
Open Source Computer Vision
Functions
Graph API: Image Structural Analysis and Shape Descriptors

Functions

GOpaque< Rectcv::gapi::boundingRect (const GMat &src)
 Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image. More...
 
GOpaque< Rectcv::gapi::boundingRect (const GArray< Point2i > &src)
 
GOpaque< Rectcv::gapi::boundingRect (const GArray< Point2f > &src)
 
GArray< GArray< Point > > cv::gapi::findContours (const GMat &src, const RetrievalModes mode, const ContourApproximationModes method, const GOpaque< Point > &offset)
 Finds contours in a binary image. More...
 
GArray< GArray< Point > > cv::gapi::findContours (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)
 Finds contours and their hierarchy in a binary image. More...
 
std::tuple< GArray< GArray< Point > >, GArray< Vec4i > > cv::gapi::findContoursH (const GMat &src, const RetrievalModes mode, const ContourApproximationModes method)
 
GOpaque< Vec4fcv::gapi::fitLine2D (const GMat &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 Fits a line to a 2D point set. More...
 
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 GArray< Point2f > &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 
GOpaque< Vec4fcv::gapi::fitLine2D (const GArray< Point2d > &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.)
 Fits a line to a 3D point set. More...
 
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 GArray< Point3f > &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 
GOpaque< Vec6fcv::gapi::fitLine3D (const GArray< Point3d > &src, const DistanceTypes distType, const double param=0., const double reps=0., const double aeps=0.)
 

Detailed Description

Function Documentation

◆ boundingRect() [1/3]

GOpaque<Rect> cv::gapi::boundingRect ( const GMat src)

#include <opencv2/gapi/imgproc.hpp>

Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image.

The function calculates and returns the minimal up-right bounding rectangle for the specified point set or non-zero pixels of gray-scale image.

Note
  • Function textual ID is "org.opencv.imgproc.shape.boundingRectMat"
  • In case of a 2D points' set given, Mat should be 2-dimensional, have a single row or column if there are 2 channels, or have 2 columns if there is a single channel. Mat should have either CV_32S or CV_32F depth
Parameters
srcInput gray-scale image CV_8UC1; or input set of CV_32S or CV_32F 2D points stored in Mat.

◆ boundingRect() [2/3]

GOpaque<Rect> cv::gapi::boundingRect ( const GArray< Point2i > &  src)

#include <opencv2/gapi/imgproc.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Calculates the up-right bounding rectangle of a point set.

Note
Function textual ID is "org.opencv.imgproc.shape.boundingRectVector32S"
Parameters
srcInput 2D point set, stored in std::vector<cv::Point2i>.

◆ boundingRect() [3/3]

GOpaque<Rect> cv::gapi::boundingRect ( const GArray< Point2f > &  src)

#include <opencv2/gapi/imgproc.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Calculates the up-right bounding rectangle of a point set.

Note
Function textual ID is "org.opencv.imgproc.shape.boundingRectVector32F"
Parameters
srcInput 2D point set, stored in std::vector<cv::Point2f>.

◆ findContours() [1/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>

Finds contours in a binary image.

The function retrieves contours from the binary image using the algorithm [227] . The contours are a useful tool for shape analysis and object detection and recognition. See squares.cpp in the OpenCV sample directory.

Note
Function textual ID is "org.opencv.imgproc.shape.findContours"
Parameters
srcInput gray-scale image CV_8UC1. Non-zero pixels are treated as 1's. Zero pixels remain 0's, so the image is treated as binary . You can use compare, inRange, threshold , adaptiveThreshold, Canny, and others to create a binary image out of a grayscale or color one. If mode equals to RETR_CCOMP, the input can also be a 32-bit integer image of labels ( CV_32SC1 ). If RETR_FLOODFILL then CV_32SC1 is supported only.
modeContour retrieval mode, see RetrievalModes
methodContour approximation method, see ContourApproximationModes
offsetOptional offset by which every contour point is shifted. This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.
Returns
GArray of detected contours. Each contour is stored as a GArray of points.

◆ findContours() [2/2]

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

#include <opencv2/gapi/imgproc.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
Function textual ID is "org.opencv.imgproc.shape.findContoursNoOffset"

◆ findContoursH() [1/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>

Finds contours and their hierarchy in a binary image.

The function retrieves contours from the binary image using the algorithm [227] and calculates their hierarchy. The contours are a useful tool for shape analysis and object detection and recognition. See squares.cpp in the OpenCV sample directory.

Note
Function textual ID is "org.opencv.imgproc.shape.findContoursH"
Parameters
srcInput gray-scale image CV_8UC1. Non-zero pixels are treated as 1's. Zero pixels remain 0's, so the image is treated as binary . You can use compare, inRange, threshold , adaptiveThreshold, Canny, and others to create a binary image out of a grayscale or color one. If mode equals to RETR_CCOMP, the input can also be a 32-bit integer image of labels ( CV_32SC1 ). If RETR_FLOODFILLCV_32SC1 supports only.
modeContour retrieval mode, see RetrievalModes
methodContour approximation method, see ContourApproximationModes
offsetOptional offset by which every contour point is shifted. This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.
Returns
  • GArray of detected contours. Each contour is stored as a GArray of points.
  • Optional output GArray of cv::Vec4i, containing information about the image topology. It has as many elements as the number of contours. For each i-th contour contours[i], the elements hierarchy[i][0] , hierarchy[i][1] , hierarchy[i][2] , and hierarchy[i][3] are set to 0-based indices in contours of the next and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.

◆ findContoursH() [2/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>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
Function textual ID is "org.opencv.imgproc.shape.findContoursHNoOffset"

◆ fitLine2D() [1/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>

Fits a line to a 2D point set.

The function fits a line to a 2D point set by minimizing \(\sum_i \rho(r_i)\) where \(r_i\) is a distance between the \(i^{th}\) point, the line and \(\rho(r)\) is a distance function, one of the following:

  • 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\]

The algorithm is based on the M-estimator ( http://en.wikipedia.org/wiki/M-estimator ) technique that iteratively fits the line using the weighted least-squares algorithm. After each iteration the weights \(w_i\) are adjusted to be inversely proportional to \(\rho(r_i)\) .

Note
  • Function textual ID is "org.opencv.imgproc.shape.fitLine2DMat"
  • In case of an N-dimentional points' set given, Mat should be 2-dimensional, have a single row or column if there are N channels, or have N columns if there is a single channel.
Parameters
srcInput set of 2D points stored in one of possible containers: Mat, std::vector<cv::Point2i>, std::vector<cv::Point2f>, std::vector<cv::Point2d>.
distTypeDistance used by the M-estimator, see DistanceTypes. DIST_USER and DIST_C are not suppored.
paramNumerical parameter ( C ) for some types of distances. If it is 0, an optimal value is chosen.
repsSufficient accuracy for the radius (distance between the coordinate origin and the line). 1.0 would be a good default value for reps. If it is 0, a default value is chosen.
aepsSufficient accuracy for the angle. 0.01 would be a good default value for aeps. If it is 0, a default value is chosen.
Returns
Output line parameters: a vector of 4 elements (like Vec4f) - (vx, vy, x0, y0), where (vx, vy) is a normalized vector collinear to the line and (x0, y0) is a point on the line.

◆ fitLine2D() [2/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>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
Function textual ID is "org.opencv.imgproc.shape.fitLine2DVector32S"

◆ fitLine2D() [3/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>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
Function textual ID is "org.opencv.imgproc.shape.fitLine2DVector32F"

◆ fitLine2D() [4/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>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
Function textual ID is "org.opencv.imgproc.shape.fitLine2DVector64F"

◆ fitLine3D() [1/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>

Fits a line to a 3D point set.

The function fits a line to a 3D point set by minimizing \(\sum_i \rho(r_i)\) where \(r_i\) is a distance between the \(i^{th}\) point, the line and \(\rho(r)\) is a distance function, one of the following:

  • 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\]

The algorithm is based on the M-estimator ( http://en.wikipedia.org/wiki/M-estimator ) technique that iteratively fits the line using the weighted least-squares algorithm. After each iteration the weights \(w_i\) are adjusted to be inversely proportional to \(\rho(r_i)\) .

Note
  • Function textual ID is "org.opencv.imgproc.shape.fitLine3DMat"
  • In case of an N-dimentional points' set given, Mat should be 2-dimensional, have a single row or column if there are N channels, or have N columns if there is a single channel.
Parameters
srcInput set of 3D points stored in one of possible containers: Mat, std::vector<cv::Point3i>, std::vector<cv::Point3f>, std::vector<cv::Point3d>.
distTypeDistance used by the M-estimator, see DistanceTypes. DIST_USER and DIST_C are not suppored.
paramNumerical parameter ( C ) for some types of distances. If it is 0, an optimal value is chosen.
repsSufficient accuracy for the radius (distance between the coordinate origin and the line). 1.0 would be a good default value for reps. If it is 0, a default value is chosen.
aepsSufficient accuracy for the angle. 0.01 would be a good default value for aeps. If it is 0, a default value is chosen.
Returns
Output line parameters: a vector of 6 elements (like Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a normalized vector collinear to the line and (x0, y0, z0) is a point on the line.

◆ fitLine3D() [2/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>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
Function textual ID is "org.opencv.imgproc.shape.fitLine3DVector32S"

◆ fitLine3D() [3/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>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
Function textual ID is "org.opencv.imgproc.shape.fitLine3DVector32F"

◆ fitLine3D() [4/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>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
Function textual ID is "org.opencv.imgproc.shape.fitLine3DVector64F"