OpenCV  4.1.1-pre
Open Source Computer Vision
Looking for a C++ dev who knows OpenCV?
I'm looking for work. Hire me!
Graph API: Math operations
Collaboration diagram for Graph API: Math operations:

Functions

GMat cv::gapi::add (const GMat &src1, const GMat &src2, int ddepth=-1)
 Calculates the per-element sum of two matrices. More...
 
GMat cv::gapi::addC (const GMat &src1, const GScalar &c, int ddepth=-1)
 Calculates the per-element sum of matrix and given scalar. More...
 
GMat cv::gapi::addC (const GScalar &c, const GMat &src1, int ddepth=-1)
 
std::tuple< GMat, GMatcv::gapi::cartToPolar (const GMat &x, const GMat &y, bool angleInDegrees=false)
 Calculates the magnitude and angle of 2D vectors. More...
 
GMat cv::gapi::div (const GMat &src1, const GMat &src2, double scale, int ddepth=-1)
 Performs per-element division of two matrices. More...
 
GMat cv::gapi::divC (const GMat &src, const GScalar &divisor, double scale, int ddepth=-1)
 Divides matrix by scalar. More...
 
GMat cv::gapi::divRC (const GScalar &divident, const GMat &src, double scale, int ddepth=-1)
 Divides scalar by matrix. More...
 
GMat cv::gapi::mask (const GMat &src, const GMat &mask)
 Applies a mask to a matrix. More...
 
GScalar cv::gapi::mean (const GMat &src)
 Calculates an average (mean) of matrix elements. More...
 
GMat cv::gapi::mul (const GMat &src1, const GMat &src2, double scale=1.0, int ddepth=-1)
 Calculates the per-element scaled product of two matrices. More...
 
GMat cv::gapi::mulC (const GMat &src, double multiplier, int ddepth=-1)
 Multiplies matrix by scalar. More...
 
GMat cv::gapi::mulC (const GMat &src, const GScalar &multiplier, int ddepth=-1)
 
GMat cv::gapi::mulC (const GScalar &multiplier, const GMat &src, int ddepth=-1)
 
GMat cv::gapi::phase (const GMat &x, const GMat &y, bool angleInDegrees=false)
 Calculates the rotation angle of 2D vectors. More...
 
std::tuple< GMat, GMatcv::gapi::polarToCart (const GMat &magnitude, const GMat &angle, bool angleInDegrees=false)
 Calculates x and y coordinates of 2D vectors from their magnitude and angle. More...
 
GMat cv::gapi::sqrt (const GMat &src)
 Calculates a square root of array elements. More...
 
GMat cv::gapi::sub (const GMat &src1, const GMat &src2, int ddepth=-1)
 Calculates the per-element difference between two matrices. More...
 
GMat cv::gapi::subC (const GMat &src, const GScalar &c, int ddepth=-1)
 Calculates the per-element difference between matrix and given scalar. More...
 
GMat cv::gapi::subRC (const GScalar &c, const GMat &src, int ddepth=-1)
 Calculates the per-element difference between given scalar and the matrix. More...
 

Detailed Description

Function Documentation

◆ add()

GMat cv::gapi::add ( const GMat src1,
const GMat src2,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Calculates the per-element sum of two matrices.

The function add calculates sum of two matrices of the same size and the same number of channels:

\[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\]

The function can be replaced with matrix expressions:

\[\texttt{dst} = \texttt{src1} + \texttt{src2}\]

The input matrices and the output matrix can all have the same or different depths. For example, you can add a 16-bit unsigned matrix to a 8-bit signed matrix and store the sum as a 32-bit floating-point matrix. Depth of the output matrix is determined by the ddepth parameter. If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have the same depth as the input matrices.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.add"
Parameters
src1first input matrix.
src2second input matrix.
ddepthoptional depth of the output matrix.
See also
sub, addWeighted

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ addC() [1/2]

GMat cv::gapi::addC ( const GMat src1,
const GScalar c,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Calculates the per-element sum of matrix and given scalar.

The function addC adds a given scalar value to each element of given matrix. The function can be replaced with matrix expressions:

\[\texttt{dst} = \texttt{src1} + \texttt{c}\]

Depth of the output matrix is determined by the ddepth parameter. If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix. The matrices can be single or multi channel. Output matrix must have the same size and number of channels as the input matrix.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.addC"
Parameters
src1first input matrix.
cscalar value to be added.
ddepthoptional depth of the output matrix.
See also
sub, addWeighted

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ addC() [2/2]

GMat cv::gapi::addC ( const GScalar c,
const GMat src1,
int  ddepth = -1 
)

#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.

◆ cartToPolar()

std::tuple<GMat, GMat> cv::gapi::cartToPolar ( const GMat x,
const GMat y,
bool  angleInDegrees = false 
)

#include <opencv2/gapi/core.hpp>

Calculates the magnitude and angle of 2D vectors.

The function cartToPolar calculates either the magnitude, angle, or both for every 2D vector (x(I),y(I)):

\[\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\]

The angles are calculated with accuracy about 0.3 degrees. For the point (0,0), the angle is set to 0.

First output is a matrix of magnitudes of the same size and depth as input x. Second output is a matrix of angles that has the same size and depth as x; the angles are measured in radians (from 0 to 2*Pi) or in degrees (0 to 360 degrees).

Note
Function textual ID is "org.opencv.core.math.cartToPolar"
Parameters
xmatrix of CV_32FC1 x-coordinates.
yarray of CV_32FC1 y-coordinates.
angleInDegreesa flag, indicating whether the angles are measured in radians (which is by default), or in degrees.
See also
polarToCart

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ div()

GMat cv::gapi::div ( const GMat src1,
const GMat src2,
double  scale,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Performs per-element division of two matrices.

The function divides one matrix by another:

\[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\]

When src2(I) is zero, dst(I) will also be zero. Different channels of multi-channel matrices are processed independently. The matrices can be single or multi channel. Output matrix must have the same size and depth as src.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.div"
Parameters
src1first input matrix.
src2second input matrix of the same size and depth as src1.
scalescalar factor.
ddepthoptional depth of the output matrix; you can only pass -1 when src1.depth() == src2.depth().
See also
mul, add, sub

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ divC()

GMat cv::gapi::divC ( const GMat src,
const GScalar divisor,
double  scale,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Divides matrix by scalar.

The function divC divides each element of matrix src by given scalar value:

\[\texttt{dst(I) = saturate(src(I)*scale/divisor)}\]

When divisor is zero, dst(I) will also be zero. Different channels of multi-channel matrices are processed independently. The matrices can be single or multi channel. Output matrix must have the same size and depth as src.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.divC"
Parameters
srcinput matrix.
divisornumber to be divided by.
ddepthoptional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth.
scalescale factor.
See also
add, sub, div, addWeighted

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ divRC()

GMat cv::gapi::divRC ( const GScalar divident,
const GMat src,
double  scale,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Divides scalar by matrix.

The function divRC divides given scalar by each element of matrix src and keep the division result in new matrix of the same size and type as src:

\[\texttt{dst(I) = saturate(divident*scale/src(I))}\]

When src(I) is zero, dst(I) will also be zero. Different channels of multi-channel matrices are processed independently. The matrices can be single or multi channel. Output matrix must have the same size and depth as src.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.divRC"
Parameters
srcinput matrix.
dividentnumber to be divided.
ddepthoptional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth.
scalescale factor
See also
add, sub, div, addWeighted

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ mask()

◆ mean()

GScalar cv::gapi::mean ( const GMat src)

#include <opencv2/gapi/core.hpp>

Calculates an average (mean) of matrix elements.

The function mean calculates the mean value M of matrix elements, independently for each channel, and return it.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.mean"
Parameters
srcinput matrix.

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ mul()

GMat cv::gapi::mul ( const GMat src1,
const GMat src2,
double  scale = 1.0,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Calculates the per-element scaled product of two matrices.

The function mul calculates the per-element product of two matrices:

\[\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\]

If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have the same depth as the input matrices. The matrices can be single or multi channel. Output matrix must have the same size as input matrices.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.mul"
Parameters
src1first input matrix.
src2second input matrix of the same size and the same depth as src1.
scaleoptional scale factor.
ddepthoptional depth of the output matrix.
See also
add, sub, div, addWeighted

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ mulC() [1/3]

GMat cv::gapi::mulC ( const GMat src,
double  multiplier,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Multiplies matrix by scalar.

The function mulC multiplies each element of matrix src by given scalar value:

\[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I) \cdot \texttt{multiplier} )\]

The matrices can be single or multi channel. Output matrix must have the same size as src.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.mulC"
Parameters
srcinput matrix.
multiplierfactor to be multiplied.
ddepthoptional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth.
See also
add, sub, div, addWeighted

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ mulC() [2/3]

GMat cv::gapi::mulC ( const GMat src,
const GScalar multiplier,
int  ddepth = -1 
)

#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.

◆ mulC() [3/3]

GMat cv::gapi::mulC ( const GScalar multiplier,
const GMat src,
int  ddepth = -1 
)

#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.

◆ phase()

GMat cv::gapi::phase ( const GMat x,
const GMat y,
bool  angleInDegrees = false 
)

#include <opencv2/gapi/core.hpp>

Calculates the rotation angle of 2D vectors.

The function cv::phase calculates the rotation angle of each 2D vector that is formed from the corresponding elements of x and y :

\[\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\]

The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 , the corresponding angle(I) is set to 0.

Parameters
xinput floating-point array of x-coordinates of 2D vectors.
yinput array of y-coordinates of 2D vectors; it must have the same size and the same type as x.
angleInDegreeswhen true, the function calculates the angle in degrees, otherwise, they are measured in radians.
Returns
array of vector angles; it has the same size and same type as x.

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ polarToCart()

std::tuple<GMat, GMat> cv::gapi::polarToCart ( const GMat magnitude,
const GMat angle,
bool  angleInDegrees = false 
)

#include <opencv2/gapi/core.hpp>

Calculates x and y coordinates of 2D vectors from their magnitude and angle.

The function polarToCart calculates the Cartesian coordinates of each 2D vector represented by the corresponding elements of magnitude and angle:

\[\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\]

The relative accuracy of the estimated coordinates is about 1e-6.

First output is a matrix of x-coordinates of 2D vectors. Second output is a matrix of y-coordinates of 2D vectors. Both output must have the same size and depth as input matrices.

Note
Function textual ID is "org.opencv.core.math.polarToCart"
Parameters
magnitudeinput floating-point CV_32FC1 matrix (1xN) of magnitudes of 2D vectors;
angleinput floating-point CV_32FC1 matrix (1xN) of angles of 2D vectors.
angleInDegreeswhen true, the input angles are measured in degrees, otherwise, they are measured in radians.
See also
cartToPolar, exp, log, pow, sqrt

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ sqrt()

GMat cv::gapi::sqrt ( const GMat src)

#include <opencv2/gapi/core.hpp>

Calculates a square root of array elements.

The function cv::gapi::sqrt calculates a square root of each input array element. In case of multi-channel arrays, each channel is processed independently. The accuracy is approximately the same as of the built-in std::sqrt .

Parameters
srcinput floating-point array.
Returns
output array of the same size and type as src.

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ sub()

GMat cv::gapi::sub ( const GMat src1,
const GMat src2,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Calculates the per-element difference between two matrices.

The function sub calculates difference between two matrices, when both matrices have the same size and the same number of channels:

\[\texttt{dst}(I) = \texttt{src1}(I) - \texttt{src2}(I)\]

The function can be replaced with matrix expressions:

\[\texttt{dst} = \texttt{src1} - \texttt{src2}\]

The input matrices and the output matrix can all have the same or different depths. For example, you can subtract two 8-bit unsigned matrices store the result as a 16-bit signed matrix. Depth of the output matrix is determined by the ddepth parameter. If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have the same depth as the input matrices. The matrices can be single or multi channel.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.sub"
Parameters
src1first input matrix.
src2second input matrix.
ddepthoptional depth of the output matrix.
See also
add, addC

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ subC()

GMat cv::gapi::subC ( const GMat src,
const GScalar c,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Calculates the per-element difference between matrix and given scalar.

The function can be replaced with matrix expressions:

\[\texttt{dst} = \texttt{src} - \texttt{c}\]

Depth of the output matrix is determined by the ddepth parameter. If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix. The matrices can be single or multi channel. Output matrix must have the same size as src.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.subC"
Parameters
srcfirst input matrix.
cscalar value to subtracted.
ddepthoptional depth of the output matrix.
See also
add, addC, subRC

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function:

◆ subRC()

GMat cv::gapi::subRC ( const GScalar c,
const GMat src,
int  ddepth = -1 
)

#include <opencv2/gapi/core.hpp>

Calculates the per-element difference between given scalar and the matrix.

The function can be replaced with matrix expressions:

\[\texttt{dst} = \texttt{val} - \texttt{src}\]

Depth of the output matrix is determined by the ddepth parameter. If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix. The matrices can be single or multi channel. Output matrix must have the same size as src.

Supported matrix data types are CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1.

Note
Function textual ID is "org.opencv.core.math.subRC"
Parameters
cscalar value to subtract from.
srcinput matrix to be subtracted.
ddepthoptional depth of the output matrix.
See also
add, addC, subC

Referenced by cv::gapi::core::G_TYPED_KERNEL().

Here is the caller graph for this function: