OpenCV  4.5.4
Open Source Computer Vision
Functions
Graph API: Image and channel composition functions

Functions

GMat cv::gapi::concatHor (const GMat &src1, const GMat &src2)
 Applies horizontal concatenation to given matrices. More...
 
GMat cv::gapi::concatHor (const std::vector< GMat > &v)
 
GMat cv::gapi::concatVert (const GMat &src1, const GMat &src2)
 Applies vertical concatenation to given matrices. More...
 
GMat cv::gapi::concatVert (const std::vector< GMat > &v)
 
GMat cv::gapi::convertTo (const GMat &src, int rdepth, double alpha=1, double beta=0)
 Converts a matrix to another data depth with optional scaling. More...
 
GMat cv::gapi::copy (const GMat &in)
 Makes a copy of the input image. Note that this copy may be not real (no actual data copied). Use this function to maintain graph contracts, e.g when graph's input needs to be passed directly to output, like in Streaming mode. More...
 
GFrame cv::gapi::copy (const GFrame &in)
 Makes a copy of the input frame. Note that this copy may be not real (no actual data copied). Use this function to maintain graph contracts, e.g when graph's input needs to be passed directly to output, like in Streaming mode. More...
 
GMat cv::gapi::crop (const GMat &src, const Rect &rect)
 Crops a 2D matrix. More...
 
GMat cv::gapi::flip (const GMat &src, int flipCode)
 Flips a 2D matrix around vertical, horizontal, or both axes. More...
 
GMat cv::gapi::LUT (const GMat &src, const Mat &lut)
 Performs a look-up table transform of a matrix. More...
 
GMat cv::gapi::merge3 (const GMat &src1, const GMat &src2, const GMat &src3)
 Creates one 3-channel matrix out of 3 single-channel ones. More...
 
GMat cv::gapi::merge4 (const GMat &src1, const GMat &src2, const GMat &src3, const GMat &src4)
 Creates one 4-channel matrix out of 4 single-channel ones. More...
 
GMat cv::gapi::normalize (const GMat &src, double alpha, double beta, int norm_type, int ddepth=-1)
 Normalizes the norm or value range of an array. More...
 
GMat cv::gapi::remap (const GMat &src, const Mat &map1, const Mat &map2, int interpolation, int borderMode=BORDER_CONSTANT, const Scalar &borderValue=Scalar())
 Applies a generic geometrical transformation to an image. More...
 
GMat cv::gapi::resize (const GMat &src, const Size &dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR)
 Resizes an image. More...
 
GMatP cv::gapi::resizeP (const GMatP &src, const Size &dsize, int interpolation=cv::INTER_LINEAR)
 Resizes a planar image. More...
 
std::tuple< GMat, GMat, GMatcv::gapi::split3 (const GMat &src)
 Divides a 3-channel matrix into 3 single-channel matrices. More...
 
std::tuple< GMat, GMat, GMat, GMatcv::gapi::split4 (const GMat &src)
 Divides a 4-channel matrix into 4 single-channel matrices. More...
 
GMat cv::gapi::warpAffine (const GMat &src, const Mat &M, const Size &dsize, int flags=cv::INTER_LINEAR, int borderMode=cv::BORDER_CONSTANT, const Scalar &borderValue=Scalar())
 Applies an affine transformation to an image. More...
 
GMat cv::gapi::warpPerspective (const GMat &src, const Mat &M, const Size &dsize, int flags=cv::INTER_LINEAR, int borderMode=cv::BORDER_CONSTANT, const Scalar &borderValue=Scalar())
 Applies a perspective transformation to an image. More...
 

Detailed Description

Function Documentation

◆ concatHor() [1/2]

GMat cv::gapi::concatHor ( const GMat src1,
const GMat src2 
)

#include <opencv2/gapi/core.hpp>

Applies horizontal concatenation to given matrices.

The function horizontally concatenates two GMat matrices (with the same number of rows).

GMat A = { 1, 4,
2, 5,
3, 6 };
GMat B = { 7, 10,
8, 11,
9, 12 };
GMat C = gapi::concatHor(A, B);
//C:
//[1, 4, 7, 10;
// 2, 5, 8, 11;
// 3, 6, 9, 12]

Output matrix must the same number of rows and depth as the src1 and src2, and the sum of cols of the src1 and src2. Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.imgproc.transform.concatHor"
Parameters
src1first input matrix to be considered for horizontal concatenation.
src2second input matrix to be considered for horizontal concatenation.
See also
concatVert

◆ concatHor() [2/2]

GMat cv::gapi::concatHor ( const std::vector< GMat > &  v)

#include <opencv2/gapi/core.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The function horizontally concatenates given number of GMat matrices (with the same number of columns). Output matrix must the same number of columns and depth as the input matrices, and the sum of rows of input matrices.

Parameters
vvector of input matrices to be concatenated horizontally.

◆ concatVert() [1/2]

GMat cv::gapi::concatVert ( const GMat src1,
const GMat src2 
)

#include <opencv2/gapi/core.hpp>

Applies vertical concatenation to given matrices.

The function vertically concatenates two GMat matrices (with the same number of cols).

GMat A = { 1, 7,
2, 8,
3, 9 };
GMat B = { 4, 10,
5, 11,
6, 12 };
GMat C = gapi::concatVert(A, B);
//C:
//[1, 7;
// 2, 8;
// 3, 9;
// 4, 10;
// 5, 11;
// 6, 12]

Output matrix must the same number of cols and depth as the src1 and src2, and the sum of rows of the src1 and src2. Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.imgproc.transform.concatVert"
Parameters
src1first input matrix to be considered for vertical concatenation.
src2second input matrix to be considered for vertical concatenation.
See also
concatHor

◆ concatVert() [2/2]

GMat cv::gapi::concatVert ( const std::vector< GMat > &  v)

#include <opencv2/gapi/core.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The function vertically concatenates given number of GMat matrices (with the same number of columns). Output matrix must the same number of columns and depth as the input matrices, and the sum of rows of input matrices.

Parameters
vvector of input matrices to be concatenated vertically.

◆ convertTo()

GMat cv::gapi::convertTo ( const GMat src,
int  rdepth,
double  alpha = 1,
double  beta = 0 
)

#include <opencv2/gapi/core.hpp>

Converts a matrix to another data depth with optional scaling.

The method converts source pixel values to the target data depth. saturate_cast<> is applied at the end to avoid possible overflows:

\[m(x,y) = saturate \_ cast<rType>( \alpha (*this)(x,y) + \beta )\]

Output matrix must be of the same size as input one.

Note
Function textual ID is "org.opencv.core.transform.convertTo"
Parameters
srcinput matrix to be converted from.
rdepthdesired output matrix depth or, rather, the depth since the number of channels are the same as the input has; if rdepth is negative, the output matrix will have the same depth as the input.
alphaoptional scale factor.
betaoptional delta added to the scaled values.
Examples:
samples/cpp/stitching_detailed.cpp.

◆ copy() [1/2]

GMat cv::gapi::copy ( const GMat in)
Python:
cv.gapi.copy(in_) -> retval

#include <opencv2/gapi/streaming/format.hpp>

Makes a copy of the input image. Note that this copy may be not real (no actual data copied). Use this function to maintain graph contracts, e.g when graph's input needs to be passed directly to output, like in Streaming mode.

Note
Function textual ID is "org.opencv.streaming.copy"
Parameters
inInput image
Returns
Copy of the input

◆ copy() [2/2]

GFrame cv::gapi::copy ( const GFrame in)
Python:
cv.gapi.copy(in_) -> retval

#include <opencv2/gapi/streaming/format.hpp>

Makes a copy of the input frame. Note that this copy may be not real (no actual data copied). Use this function to maintain graph contracts, e.g when graph's input needs to be passed directly to output, like in Streaming mode.

Note
Function textual ID is "org.opencv.streaming.copy"
Parameters
inInput frame
Returns
Copy of the input

◆ crop()

GMat cv::gapi::crop ( const GMat src,
const Rect rect 
)

#include <opencv2/gapi/core.hpp>

Crops a 2D matrix.

The function crops the matrix by given cv::Rect.

Output matrix must be of the same depth as input one, size is specified by given rect size.

Note
Function textual ID is "org.opencv.core.transform.crop"
Parameters
srcinput matrix.
recta rect to crop a matrix to
See also
resize
Examples:
samples/dnn/classification.cpp.

◆ flip()

GMat cv::gapi::flip ( const GMat src,
int  flipCode 
)

#include <opencv2/gapi/core.hpp>

Flips a 2D matrix around vertical, horizontal, or both axes.

The function flips the matrix in one of three different ways (row and column indices are 0-based):

\[\texttt{dst} _{ij} = \left\{ \begin{array}{l l} \texttt{src} _{\texttt{src.rows}-i-1,j} & if\; \texttt{flipCode} = 0 \\ \texttt{src} _{i, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} > 0 \\ \texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} < 0 \\ \end{array} \right.\]

The example scenarios of using the function are the following: Vertical flipping of the image (flipCode == 0) to switch between top-left and bottom-left image origin. This is a typical operation in video processing on Microsoft Windows* OS. Horizontal flipping of the image with the subsequent horizontal shift and absolute difference calculation to check for a vertical-axis symmetry (flipCode > 0). Simultaneous horizontal and vertical flipping of the image with the subsequent shift and absolute difference calculation to check for a central symmetry (flipCode < 0). Reversing the order of point arrays (flipCode > 0 or flipCode == 0). Output image must be of the same depth as input one, size should be correct for given flipCode.

Note
Function textual ID is "org.opencv.core.transform.flip"
Parameters
srcinput matrix.
flipCodea flag to specify how to flip the array; 0 means flipping around the x-axis and positive value (for example, 1) means flipping around y-axis. Negative value (for example, -1) means flipping around both axes.
See also
remap

◆ LUT()

GMat cv::gapi::LUT ( const GMat src,
const Mat lut 
)

#include <opencv2/gapi/core.hpp>

Performs a look-up table transform of a matrix.

The function LUT fills the output matrix with values from the look-up table. Indices of the entries are taken from the input matrix. That is, the function processes each element of src as follows:

\[\texttt{dst} (I) \leftarrow \texttt{lut(src(I))}\]

Supported matrix data types are CV_8UC1. Output is a matrix of the same size and number of channels as src, and the same depth as lut.

Note
Function textual ID is "org.opencv.core.transform.LUT"
Parameters
srcinput matrix of 8-bit elements.
lutlook-up table of 256 elements; in case of multi-channel input array, the table should either have a single channel (in this case the same table is used for all channels) or the same number of channels as in the input matrix.

◆ merge3()

GMat cv::gapi::merge3 ( const GMat src1,
const GMat src2,
const GMat src3 
)

#include <opencv2/gapi/core.hpp>

Creates one 3-channel matrix out of 3 single-channel ones.

The function merges several matrices to make a single multi-channel matrix. That is, each element of the output matrix will be a concatenation of the elements of the input matrices, where elements of i-th input matrix are treated as mv[i].channels()-element vectors. Output matrix must be of CV_8UC3 type.

The function split3 does the reverse operation.

Note
  • Function textual ID is "org.opencv.core.transform.merge3"
Parameters
src1first input CV_8UC1 matrix to be merged.
src2second input CV_8UC1 matrix to be merged.
src3third input CV_8UC1 matrix to be merged.
See also
merge4, split4, split3

◆ merge4()

GMat cv::gapi::merge4 ( const GMat src1,
const GMat src2,
const GMat src3,
const GMat src4 
)

#include <opencv2/gapi/core.hpp>

Creates one 4-channel matrix out of 4 single-channel ones.

The function merges several matrices to make a single multi-channel matrix. That is, each element of the output matrix will be a concatenation of the elements of the input matrices, where elements of i-th input matrix are treated as mv[i].channels()-element vectors. Output matrix must be of CV_8UC4 type.

The function split4 does the reverse operation.

Note
  • Function textual ID is "org.opencv.core.transform.merge4"
Parameters
src1first input CV_8UC1 matrix to be merged.
src2second input CV_8UC1 matrix to be merged.
src3third input CV_8UC1 matrix to be merged.
src4fourth input CV_8UC1 matrix to be merged.
See also
merge3, split4, split3

◆ normalize()

GMat cv::gapi::normalize ( const GMat src,
double  alpha,
double  beta,
int  norm_type,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Normalizes the norm or value range of an array.

The function normalizes scale and shift the input array elements so that

\[\| \texttt{dst} \| _{L_p}= \texttt{alpha}\]

(where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that

\[\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\]

when normType=NORM_MINMAX (for dense arrays only).

Note
Function textual ID is "org.opencv.core.normalize"
Parameters
srcinput array.
alphanorm value to normalize to or the lower range boundary in case of the range normalization.
betaupper range boundary in case of the range normalization; it is not used for the norm normalization.
norm_typenormalization type (see cv::NormTypes).
ddepthwhen negative, the output array has the same type as src; otherwise, it has the same number of channels as src and the depth =ddepth.
See also
norm, Mat::convertTo

◆ remap()

GMat cv::gapi::remap ( const GMat src,
const Mat map1,
const Mat map2,
int  interpolation,
int  borderMode = BORDER_CONSTANT,
const Scalar borderValue = Scalar() 
)

#include <opencv2/gapi/core.hpp>

Applies a generic geometrical transformation to an image.

The function remap transforms the source image using the specified map:

\[\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\]

where values of pixels with non-integer coordinates are computed using one of available interpolation methods. \(map_x\) and \(map_y\) can be encoded as separate floating-point maps in \(map_1\) and \(map_2\) respectively, or interleaved floating-point maps of \((x,y)\) in \(map_1\), or fixed-point maps created by using convertMaps. The reason you might want to convert from floating to fixed-point representations of a map is that they can yield much faster (2x) remapping operations. In the converted case, \(map_1\) contains pairs (cvFloor(x), cvFloor(y)) and \(map_2\) contains indices in a table of interpolation coefficients. Output image must be of the same size and depth as input one.

Note
  • Function textual ID is "org.opencv.core.transform.remap"
  • Due to current implementation limitations the size of an input and output images should be less than 32767x32767.
Parameters
srcSource image.
map1The first map of either (x,y) points or just x values having the type CV_16SC2, CV_32FC1, or CV_32FC2.
map2The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively.
interpolationInterpolation method (see cv::InterpolationFlags). The methods INTER_AREA and INTER_LINEAR_EXACT are not supported by this function.
borderModePixel extrapolation method (see cv::BorderTypes). When borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function.
borderValueValue used in case of a constant border. By default, it is 0.

◆ resize()

GMat cv::gapi::resize ( const GMat src,
const Size dsize,
double  fx = 0,
double  fy = 0,
int  interpolation = INTER_LINEAR 
)
Python:
cv.gapi.resize(src, dsize[, fx[, fy[, interpolation]]]) -> retval

#include <opencv2/gapi/core.hpp>

Resizes an image.

The function resizes the image src down to or up to the specified size.

Output image size will have the size dsize (when dsize is non-zero) or the size computed from src.size(), fx, and fy; the depth of output is the same as of src.

If you want to resize src so that it fits the pre-created dst, you may call the function as follows:

// explicitly specify dsize=dst.size(); fx and fy will be computed from that.
resize(src, dst, dst.size(), 0, 0, interpolation);

If you want to decimate the image by factor of 2 in each direction, you can call the function this way:

// specify fx and fy and let the function compute the destination image size.
resize(src, dst, Size(), 0.5, 0.5, interpolation);

To shrink an image, it will generally look best with cv::INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with cv::INTER_CUBIC (slow) or cv::INTER_LINEAR (faster but still looks OK).

Note
Function textual ID is "org.opencv.core.transform.resize"
Parameters
srcinput image.
dsizeoutput image size; if it equals zero, it is computed as:

\[\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\]

Either dsize or both fx and fy must be non-zero.
fxscale factor along the horizontal axis; when it equals 0, it is computed as

\[\texttt{(double)dsize.width/src.cols}\]

fyscale factor along the vertical axis; when it equals 0, it is computed as

\[\texttt{(double)dsize.height/src.rows}\]

interpolationinterpolation method, see cv::InterpolationFlags
See also
warpAffine, warpPerspective, remap, resizeP

◆ resizeP()

GMatP cv::gapi::resizeP ( const GMatP src,
const Size dsize,
int  interpolation = cv::INTER_LINEAR 
)

#include <opencv2/gapi/core.hpp>

Resizes a planar image.

The function resizes the image src down to or up to the specified size. Planar image memory layout is three planes laying in the memory contiguously, so the image height should be plane_height*plane_number, image type is CV_8UC1.

Output image size will have the size dsize, the depth of output is the same as of src.

Note
Function textual ID is "org.opencv.core.transform.resizeP"
Parameters
srcinput image, must be of CV_8UC1 type;
dsizeoutput image size;
interpolationinterpolation method, only cv::INTER_LINEAR is supported at the moment
See also
warpAffine, warpPerspective, remap, resize

◆ split3()

std::tuple<GMat, GMat, GMat> cv::gapi::split3 ( const GMat src)
Python:
cv.gapi.split3(src) -> retval

#include <opencv2/gapi/core.hpp>

Divides a 3-channel matrix into 3 single-channel matrices.

The function splits a 3-channel matrix into 3 single-channel matrices:

\[\texttt{mv} [c](I) = \texttt{src} (I)_c\]

All output matrices must be of CV_8UC1 type.

The function merge3 does the reverse operation.

Note
  • Function textual ID is "org.opencv.core.transform.split3"
Parameters
srcinput CV_8UC3 matrix.
See also
split4, merge3, merge4

◆ split4()

std::tuple<GMat, GMat, GMat,GMat> cv::gapi::split4 ( const GMat src)

#include <opencv2/gapi/core.hpp>

Divides a 4-channel matrix into 4 single-channel matrices.

The function splits a 4-channel matrix into 4 single-channel matrices:

\[\texttt{mv} [c](I) = \texttt{src} (I)_c\]

All output matrices must be of CV_8UC1 type.

The function merge4 does the reverse operation.

Note
  • Function textual ID is "org.opencv.core.transform.split4"
Parameters
srcinput CV_8UC4 matrix.
See also
split3, merge3, merge4

◆ warpAffine()

GMat cv::gapi::warpAffine ( const GMat src,
const Mat M,
const Size dsize,
int  flags = cv::INTER_LINEAR,
int  borderMode = cv::BORDER_CONSTANT,
const Scalar borderValue = Scalar() 
)

#include <opencv2/gapi/core.hpp>

Applies an affine transformation to an image.

The function warpAffine transforms the source image using the specified matrix:

\[\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\]

when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invertAffineTransform and then put in the formula above instead of M. The function cannot operate in-place.

Parameters
srcinput image.
M\(2\times 3\) transformation matrix.
dsizesize of the output image.
flagscombination of interpolation methods (see InterpolationFlags) and the optional flag WARP_INVERSE_MAP that means that M is the inverse transformation ( \(\texttt{dst}\rightarrow\texttt{src}\) ).
borderModepixel extrapolation method (see BorderTypes); borderMode=BORDER_TRANSPARENT isn't supported
borderValuevalue used in case of a constant border; by default, it is 0.
See also
warpPerspective, resize, remap, getRectSubPix, transform

◆ warpPerspective()

GMat cv::gapi::warpPerspective ( const GMat src,
const Mat M,
const Size dsize,
int  flags = cv::INTER_LINEAR,
int  borderMode = cv::BORDER_CONSTANT,
const Scalar borderValue = Scalar() 
)

#include <opencv2/gapi/core.hpp>

Applies a perspective transformation to an image.

The function warpPerspective transforms the source image using the specified matrix:

\[\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\]

when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert and then put in the formula above instead of M. The function cannot operate in-place.

Parameters
srcinput image.
M\(3\times 3\) transformation matrix.
dsizesize of the output image.
flagscombination of interpolation methods (INTER_LINEAR or INTER_NEAREST) and the optional flag WARP_INVERSE_MAP, that sets M as the inverse transformation ( \(\texttt{dst}\rightarrow\texttt{src}\) ).
borderModepixel extrapolation method (BORDER_CONSTANT or BORDER_REPLICATE).
borderValuevalue used in case of a constant border; by default, it equals 0.
See also
warpAffine, resize, remap, getRectSubPix, perspectiveTransform