Table of Contents

Class GapiInvoke

Namespace
Emgu.CV
Assembly
Emgu.CV.dll

Class that provide access to native GAPI functions from OpenCV

public static class GapiInvoke
Inheritance
GapiInvoke
Inherited Members

Methods

AbsDiff(GMat, GMat)

Calculates absolute difference between two matrices of the same size and depth

public static GMat AbsDiff(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix

Returns

GMat

Absolute difference between two matrices of the same size and depth

AbsDiffC(GMat, GScalar)

Calculates absolute difference between matrix elements and given scalar value

public static GMat AbsDiffC(GMat src, GScalar c)

Parameters

src GMat

Input matrix.

c GScalar

Scalar to be subtracted.

Returns

GMat

Absolute difference between matrix elements and given scalar value

Add(GMat, GMat, DepthType)

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

public static GMat Add(GMat src1, GMat src2, DepthType ddepth = DepthType.Default)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix.

ddepth DepthType

Optional depth of the output matrix.

Returns

GMat

Per-element sum of two matrices.

AddC(GMat, GScalar, DepthType)

The function addC adds a given scalar value to each element of given matrix.

public static GMat AddC(GMat src1, GScalar c, DepthType ddepth)

Parameters

src1 GMat

First input matrix.

c GScalar

Scalar value to be added.

ddepth DepthType

Optional depth of the output matrix.

Returns

GMat

Per-element sum of matrix and given scalar.

AddWeighted(GMat, double, GMat, double, double, DepthType)

Calculates the weighted sum of two matrices

public static GMat AddWeighted(GMat src1, double alpha, GMat src2, double beta, double gamma, DepthType ddepth)

Parameters

src1 GMat

First input matrix.

alpha double

Weight of the first matrix elements.

src2 GMat

Second input matrix of the same size and channel number as src1

beta double

Weight of the second matrix elements.

gamma double

Scalar added to each sum.

ddepth DepthType

Optional depth of the output matrix.

Returns

GMat

The weighted sum of two matrices

BGR2Gray(GMat)

Converts an image from BGR color space to gray-scaled.

public static GMat BGR2Gray(GMat src)

Parameters

src GMat

input image: 8-bit unsigned 3-channel image.

Returns

GMat

Output image, 8-bit unsigned 1-channel image.

BGR2I420(GMat)

Converts an image from BGR color space to I420 color space.

public static GMat BGR2I420(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel image

Returns

GMat

Output image, 8-bit unsigned 1-channel image. Width of I420 output image must be the same as width of input image. Height of I420 output image must be equal 3/2 from height of input image.

BGR2LUV(GMat)

Converts an image from BGR color space to LUV color space.

public static GMat BGR2LUV(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel image

Returns

GMat

Output image, 8-bit unsigned 3-channel image

BGR2RGB(GMat)

Converts an image from BGR color space to RGB color space.

public static GMat BGR2RGB(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel image.

Returns

GMat

Output image, 8-bit unsigned 3-channel image.

BGR2YUV(GMat)

Converts an image from BGR color space to YUV color space.

public static GMat BGR2YUV(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel

Returns

GMat

Output image, 8-bit unsigned 3-channel

BayerGR2RGB(GMat)

Converts an image from BayerGR color space to RGB. The function converts an input image from BayerGR color space to RGB. The conventional ranges for G, R, and B channel values are 0 to 255.

public static GMat BayerGR2RGB(GMat src)

Parameters

src GMat

input image: 8-bit unsigned 1-channel image

Returns

GMat

Output 8-bit unsigned 3-channel image

BilateralFilter(GMat, int, double, double, BorderType)

Applies the bilateral filter to an image. BilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is very slow compared to most filters.

public static GMat BilateralFilter(GMat src, int d, double sigmaColor, double sigmaSpace, BorderType borderType = BorderType.Default)

Parameters

src GMat

Source 8-bit or floating-point, 1-channel or 3-channel image.

d int

Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace.

sigmaColor double

Filter sigma in the color space. A larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting in larger areas of semi-equal color.

sigmaSpace double

Filter sigma in the coordinate space. A larger value of the parameter means that farther pixels will influence each other as long as their colors are close enough (see sigmaColor ). When d>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is proportional to sigmaSpace.

borderType BorderType

border mode used to extrapolate pixels outside of the image

Returns

GMat

Destination image of the same size and type as src.

BitwiseAnd(GMat, GMat)

Computes bitwise conjunction of the two matrices (src1 & src2) Calculates the per-element bit-wise logical conjunction of two matrices of the same size.

public static GMat BitwiseAnd(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix.

Returns

GMat

Bitwise conjunction of the two matrices (src1 & src2)

BitwiseAnd(GMat, GScalar)

Computes bitwise conjunction of a matrix and a scalar. Calculates the per-element bit-wise logical conjunction of a matrix and a scalar.

public static GMat BitwiseAnd(GMat src1, GScalar src2)

Parameters

src1 GMat

First input matrix.

src2 GScalar

Scalar value

Returns

GMat

Bitwise conjunction of a matrix and a scalar

BitwiseNot(GMat)

Calculates per-element bit-wise inversion of the input matrix

public static GMat BitwiseNot(GMat src)

Parameters

src GMat

Input matrix.

Returns

GMat

Per-element bit-wise inversion of the input matrix

BitwiseOr(GMat, GMat)

Calculates the per-element bit-wise logical disjunction of two matrices of the same size.

public static GMat BitwiseOr(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix.

Returns

GMat

Per-element bit-wise logical disjunction of two matrices of the same size.

BitwiseOr(GMat, GScalar)

Computes bitwise logical disjunction of a matrix and a scalar. Calculates the per-element bit-wise logical disjunction of a matrix and a scalar.

public static GMat BitwiseOr(GMat src1, GScalar src2)

Parameters

src1 GMat

First input matrix.

src2 GScalar

Scalar value

Returns

GMat

Bitwise logical disjunction of a matrix and a scalar

BitwiseXor(GMat, GMat)

Calculates the per-element bit-wise logical "exclusive or" of two matrices of the same size.

public static GMat BitwiseXor(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix.

Returns

GMat

The per-element bit-wise logical "exclusive or" of two matrices of the same size.

BitwiseXor(GMat, GScalar)

Calculates the per-element bit-wise logical "exclusive or" of a matrix and a scalar.

public static GMat BitwiseXor(GMat src1, GScalar src2)

Parameters

src1 GMat

First input matrix

src2 GScalar

Scalar, for which per-lemenet "logical or" operation on elements of src1 will be performed.

Returns

GMat

The per-element bit-wise logical "exclusive or" of a matrix and a scalar.

Blur(GMat, Size, Point, BorderType, MCvScalar)

Blurs an image using the normalized box filter.

public static GMat Blur(GMat src, Size ksize, Point anchor, BorderType borderType = BorderType.Default, MCvScalar borderValue = default)

Parameters

src GMat

Source image.

ksize Size

Blurring kernel size.

anchor Point

Anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.

borderType BorderType

Border mode used to extrapolate pixels outside of the image

borderValue MCvScalar

Border value in case of constant border type

Returns

GMat

Blurred image

BoxFilter(GMat, DepthType, Size, Point, bool, BorderType, MCvScalar)

Blurs an image using the box filter.

public static GMat BoxFilter(GMat src, DepthType dtype, Size ksize, Point anchor, bool normalize = true, BorderType borderType = BorderType.Default, MCvScalar borderValue = default)

Parameters

src GMat

Source image

dtype DepthType

The output image depth

ksize Size

Blurring kernel size.

anchor Point

Anchor position within the kernel. The value (−1,−1) means that the anchor is at the kernel center.

normalize bool

Specifying whether the kernel is normalized by its area or not.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of constant border type

Returns

GMat

Blurred image

Canny(GMat, double, double, int, bool)

Finds edges in an image using the Canny algorithm.

public static GMat Canny(GMat image, double threshold1, double threshold2, int apertureSize, bool L2gradient)

Parameters

image GMat

8-bit input image

threshold1 double

first threshold for the hysteresis procedure.

threshold2 double

second threshold for the hysteresis procedure.

apertureSize int

aperture size for the Sobel operator.

L2gradient bool

If true, a more accurate L2 norm should be used to calculate the image gradient magnitude.

Returns

GMat

The canny edges

CartToPolar(GMat, GMat, bool)

Calculates the magnitude and angle of 2D vectors.

public static Tuple<GMat, GMat> CartToPolar(GMat x, GMat y, bool angleInDegrees = false)

Parameters

x GMat

Matrix of CV_32FC1 x-coordinates.

y GMat

Array of CV_32FC1 y-coordinates.

angleInDegrees bool

Indicating whether the angles are measured in radians (which is by default), or in degrees.

Returns

Tuple<GMat, GMat>

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

CmpEQ(GMat, GMat)

Performs the per-element comparison of two matrices checking if elements from first matrix are equal to elements in second.

public static GMat CmpEQ(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix of the same depth as first input matrix.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

CmpEQ(GMat, GScalar)

Performs the per-element comparison of a matrix and a scalar, checking if elements from first matrix are equal to the scalar value.

public static GMat CmpEQ(GMat src1, GScalar src2)

Parameters

src1 GMat

First input matrix.

src2 GScalar

Second input scalar.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0

CmpGE(GMat, GMat)

Performs the per-element comparison of two matrices checking if elements from first matrix are greater or equal compare to elements in second.

public static GMat CmpGE(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix of the same depth as first input matrix.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

CmpGE(GMat, GScalar)

Performs the per-element comparison of two matrices checking if elements from first matrix are greater or equal compare to the scalar value.

public static GMat CmpGE(GMat src1, GScalar src2)

Parameters

src1 GMat

First input matrix.

src2 GScalar

Second input scalar.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

CmpGT(GMat, GMat)

Performs the per-element comparison of two matrices checking if elements from first matrix are greater compare to elements in second.

public static GMat CmpGT(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix of the same depth as first input matrix.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

CmpGT(GMat, GScalar)

Performs the per-element comparison of two matrices checking if elements from first matrix are greater compare to the scalar value.

public static GMat CmpGT(GMat src1, GScalar src2)

Parameters

src1 GMat

First input matrix.

src2 GScalar

Second input scalar.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

CmpLE(GMat, GMat)

Performs the per-element comparison of two matrices checking if elements from first matrix are less or equal compare to elements in second.

public static GMat CmpLE(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix of the same depth as first input matrix.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

CmpLE(GMat, GScalar)

Performs the per-element comparison of two matrices checking if elements from first matrix are less or equal compare to the scalar value.

public static GMat CmpLE(GMat src1, GScalar src2)

Parameters

src1 GMat

First input matrix.

src2 GScalar

Second input scalar.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

CmpLT(GMat, GMat)

Performs the per-element comparison of two matrices checking if elements from first matrix are less than elements in second.

public static GMat CmpLT(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix of the same depth as first input matrix.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

CmpLT(GMat, GScalar)

Performs the per-element comparison of two matrices checking if elements from first matrix are less than the scalar value.

public static GMat CmpLT(GMat src1, GScalar src2)

Parameters

src1 GMat

First input matrix.

src2 GScalar

Second input scalar.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

CmpNE(GMat, GMat)

Performs the per-element comparison of two matrices checking if elements from first matrix are not equal to elements in second.

public static GMat CmpNE(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix of the same depth as first input matrix.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

CmpNE(GMat, GScalar)

Performs the per-element comparison of of a matrix and a scalar, checking if elements from first matrix are not equal to elements in second.

public static GMat CmpNE(GMat src1, GScalar src2)

Parameters

src1 GMat

First input matrix.

src2 GScalar

Second input scalar.

Returns

GMat

When the comparison result is true, the corresponding element of output array is set to 255. Otherwise it is set to 0.

ConcatHor(GMat, GMat)

Applies horizontal concatenation to given matrices.

public static GMat ConcatHor(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix to be considered for horizontal concatenation.

src2 GMat

Second input matrix to be considered for horizontal concatenation.

Returns

GMat

The horizontally concatenated matrix

ConcatHor(VectorOfGMat)

Applies horizontal concatenation to given matrices.

public static GMat ConcatHor(VectorOfGMat v)

Parameters

v VectorOfGMat

vector of input matrices to be concatenated vertically.

Returns

GMat

The horizontally concatenated matrix

ConcatVert(GMat, GMat)

Applies vertical concatenation to given matrices.

public static GMat ConcatVert(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix to be considered for vertical concatenation.

src2 GMat

Second input matrix to be considered for vertical concatenation.

Returns

GMat

The vertically concatenated matrix

ConcatVert(VectorOfGMat)

Applies vertical concatenation to given matrices.

public static GMat ConcatVert(VectorOfGMat v)

Parameters

v VectorOfGMat

vector of input matrices to be concatenated vertically.

Returns

GMat

The vertically concatenated matrix

ConvertTo(GMat, DepthType, double, double)

Converts a matrix to another data depth with optional scaling.

public static GMat ConvertTo(GMat src, DepthType rdepth, double alpha = 1, double beta = 0)

Parameters

src GMat

input matrix to be converted from.

rdepth DepthType

Desired output matrix depth.

alpha double

Optional scale factor.

beta double

Optional delta added to the scaled values.

Returns

GMat

A matrix of the specific data depth with optional scaling.

Crop(GMat, Rectangle)

Crops a 2D matrix.

public static GMat Crop(GMat src, Rectangle rect)

Parameters

src GMat

Input matrix.

rect Rectangle

A rect to crop a matrix to

Returns

GMat

The cropped matrix

Dilate(GMat, Mat, Point, int, BorderType, MCvScalar)

Dilates an image by using a specific structuring element.

public static GMat Dilate(GMat src, Mat kernel, Point anchor, int iterations = 1, BorderType borderType = BorderType.Constant, MCvScalar borderValue = default)

Parameters

src GMat

Input image.

kernel Mat

Structuring element used for dilation; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using getStructuringElement.

anchor Point

Position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.

iterations int

Number of times dilation is applied.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of a constant border

Returns

GMat

Result of the dilation

Dilate3x3(GMat, int, BorderType, MCvScalar)

Dilates an image by using 3 by 3 rectangular structuring element.

public static GMat Dilate3x3(GMat src, int iterations = 1, BorderType borderType = BorderType.Constant, MCvScalar borderValue = default)

Parameters

src GMat

Input image.

iterations int

Number of times dilation is applied.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of a constant border

Returns

GMat

Result of the dilation

Div(GMat, GMat, double, DepthType)

Performs per-element division of two matrices.

public static GMat Div(GMat src1, GMat src2, double scale, DepthType ddepth = DepthType.Default)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix of the same size and depth as src1.

scale double

Scalar factor.

ddepth DepthType

Optional depth of the output matrix

Returns

GMat

Per-element division of two matrices.

DivC(GMat, GScalar, double, DepthType)

Divides each element of matrix src by given scalar value

public static GMat DivC(GMat src1, GScalar divisor, double scale, DepthType ddepth = DepthType.Default)

Parameters

src1 GMat

Input matrix.

divisor GScalar

Number to be divided by.

scale double

Optional depth of the output matrix.

ddepth DepthType

Scale factor.

Returns

GMat

Result of the divide operation

DivRC(GScalar, GMat, double, DepthType)

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

public static GMat DivRC(GScalar divisor, GMat src, double scale, DepthType ddepth = DepthType.Default)

Parameters

divisor GScalar

Input matrix.

src GMat

Number to be divided.

scale double

Optional depth of the output matrix.

ddepth DepthType

Scale factor

Returns

GMat

Result of the divide operation

EqualizeHist(GMat)

The function equalizes the histogram of the input image

public static GMat EqualizeHist(GMat src)

Parameters

src GMat

Source 8-bit single channel image.

Returns

GMat

The normalized image

Erode(GMat, Mat, Point, int, BorderType, MCvScalar)

Erodes an image by using a specific structuring element

public static GMat Erode(GMat src, Mat kernel, Point anchor, int iterations = 1, BorderType borderType = BorderType.Constant, MCvScalar borderValue = default)

Parameters

src GMat

Input image

kernel Mat

Structuring element used for erosion;

anchor Point

Position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.

iterations int

Number of times erosion is applied.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of a constant border

Returns

GMat

The eroded image.

Erode3x3(GMat, int, BorderType, MCvScalar)

Erodes an image by using 3 by 3 rectangular structuring element.

public static GMat Erode3x3(GMat src, int iterations = 1, BorderType borderType = BorderType.Constant, MCvScalar borderValue = default)

Parameters

src GMat

Input image

iterations int

Number of times erosion is applied.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of a constant border

Returns

GMat

The eroded image.

Filter2D(GMat, DepthType, Mat, Point, MCvScalar, BorderType, MCvScalar)

Convolve an image with the kernel.

public static GMat Filter2D(GMat src, DepthType ddepth, Mat kernel, Point anchor, MCvScalar delta = default, BorderType borderType = BorderType.Default, MCvScalar borderValue = default)

Parameters

src GMat

Input image.

ddepth DepthType

Desired depth of the destination image

kernel Mat

Convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using split and process them individually.

anchor Point

Anchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center.

delta MCvScalar

Optional value added to the filtered pixels before storing them in dst.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of constant border type

Returns

GMat

Resulting image from the convolution filter.

Flip(GMat, FlipType)

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

public static GMat Flip(GMat src, FlipType flipCode)

Parameters

src GMat

Input matrix.

flipCode FlipType

A flag to specify how to flip the array.

Returns

GMat

The flipped GMat.

GaussianBlur(GMat, Size, double, double, BorderType, MCvScalar)

Blurs an image using a Gaussian filter.

public static GMat GaussianBlur(GMat src, Size kSize, double sigmaX, double sigmaY = 0, BorderType borderType = BorderType.Default, MCvScalar borderValue = default)

Parameters

src GMat

Input image

kSize Size

Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from sigma.

sigmaX double

Gaussian kernel standard deviation in X direction.

sigmaY double

Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, respectively.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of constant border type

Returns

GMat

The blurred image

I4202BGR(GMat)

Converts an image from I420 color space to BGR color space.

public static GMat I4202BGR(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 1-channel

Returns

GMat

Output image, 8-bit unsigned 3-channel

I4202RGB(GMat)

Converts an image from I420 color space to BGR color space.

public static GMat I4202RGB(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 1-channel

Returns

GMat

Output image, 8-bit unsigned 3-channel

InRange(GMat, GScalar, GScalar)

Applies range-level thresholding to a single- or multiple-channel matrix. It sets output pixel value to OxFF if the corresponding pixel value of input matrix is in specified range,or 0 otherwise.

public static GMat InRange(GMat src, GScalar threshLow, GScalar threshUp)

Parameters

src GMat

Input matrix (CV_8UC1).

threshLow GScalar

Lower boundary value.

threshUp GScalar

Upper boundary value.

Returns

GMat

Range-level thresholding to a single- or multiple-channel matrix. It sets output pixel value to OxFF if the corresponding pixel value of input matrix is in specified range,or 0 otherwise.

Integral(GMat, DepthType, DepthType)

Calculates the integral of an image.

public static Tuple<GMat, GMat> Integral(GMat src, DepthType sdepth = DepthType.Default, DepthType sqdepth = DepthType.Default)

Parameters

src GMat

Input image.

sdepth DepthType

Desired depth of the integral and the tilted integral images, CV_32S, CV_32F, or CV_64F.

sqdepth DepthType

Desired depth of the integral image of squared pixel values, CV_32F or CV_64F.

Returns

Tuple<GMat, GMat>

Two GMats, first one is the tilted integral image, second one is the integral image of squared pixel values.

LUT(GMat, Mat)

Fills the output matrix with values from the look-up table. Indices of the entries are taken from the input matrix.

public static GMat LUT(GMat src, Mat lut)

Parameters

src GMat

Input matrix of 8-bit elements.

lut Mat

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

Returns

GMat

A look-up table transform of a matrix.

LUV2BGR(GMat)

Converts an image from LUV color space to BGR color space.

public static GMat LUV2BGR(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel

Returns

GMat

Output image, 8-bit unsigned 3-channel.

Laplacian(GMat, DepthType, int, double, double, BorderType)

Calculates the Laplacian of an image.

public static GMat Laplacian(GMat src, DepthType ddepth, int ksize = 1, double scale = 1, double delta = 0, BorderType borderType = BorderType.Default)

Parameters

src GMat

Source image.

ddepth DepthType

Desired depth of the destination image.

ksize int

Aperture size used to compute the second-derivative filters.

scale double

Optional scale factor for the computed Laplacian values. By default, no scaling is applied.

delta double

Optional delta value that is added to the results prior to storing them in dst .

borderType BorderType

Pixel extrapolation method

Returns

GMat

Destination image of the same size and the same number of channels as src.

Mask(GMat, GMat)

Set value from given matrix if the corresponding pixel value in mask matrix set to true, and set the matrix value to 0 otherwise.

public static GMat Mask(GMat src, GMat mask)

Parameters

src GMat

Input matrix.

mask GMat

Input mask matrix.

Returns

GMat

Result of the mask operation

Max(GMat, GMat)

Calculates the per-element maximum of two matrices of the same size, number of channels and depth

public static GMat Max(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix of the same size and depth as src1.

Returns

GMat

The per-element maximum of two matrices of the same size, number of channels and depth

Mean(GMat)

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

public static GScalar Mean(GMat src)

Parameters

src GMat

Input matrix.

Returns

GScalar

The mean value of matrix elements, independently for each channel, and return it.

MedianBlur(GMat, int)

Blurs an image using the median filter.

public static GMat MedianBlur(GMat src, int kSize)

Parameters

src GMat

input matrix (image)

kSize int

aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ...

Returns

GMat

The blurred image

Merge3(GMat, GMat, GMat)

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

public static GMat Merge3(GMat src1, GMat src2, GMat src3)

Parameters

src1 GMat

First input CV_8UC1 matrix to be merged.

src2 GMat

Second input CV_8UC1 matrix to be merged.

src3 GMat

Third input CV_8UC1 matrix to be merged.

Returns

GMat

A single multi-channel matrix

Merge4(GMat, GMat, GMat, GMat)

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

public static GMat Merge4(GMat src1, GMat src2, GMat src3, GMat src4)

Parameters

src1 GMat

First input CV_8UC1 matrix to be merged.

src2 GMat

Second input CV_8UC1 matrix to be merged.

src3 GMat

Third input CV_8UC1 matrix to be merged.

src4 GMat

Fourth input CV_8UC1 matrix to be merged.

Returns

GMat

A single multi-channel matrix

Min(GMat, GMat)

Calculates the per-element minimum of two matrices of the same size, number of channels and depth

public static GMat Min(GMat src1, GMat src2)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix of the same size and depth as src1.

Returns

GMat

The per-element minimum of two matrices of the same size, number of channels and depth

MorphologyEx(GMat, MorphOp, Mat, Point, int, BorderType, MCvScalar)

Performs advanced morphological transformations.

public static GMat MorphologyEx(GMat src, MorphOp op, Mat kernel, Point anchor, int iterations = 1, BorderType borderType = BorderType.Constant, MCvScalar borderValue = default)

Parameters

src GMat

Input image.

op MorphOp

Type of a morphological operation

kernel Mat

Structuring element

anchor Point

Anchor position within the element. Both negative values mean that the anchor is at the kernel center.

iterations int

Number of times erosion and dilation are applied.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of a constant border.

Returns

GMat

Result of the morphological transformation.

Mul(GMat, GMat, double, DepthType)

Calculates the per-element scaled product of two matrices.

public static GMat Mul(GMat src1, GMat src2, double scale, DepthType ddepth)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix of the same size and the same depth as src1.

scale double

Optional scale factor.

ddepth DepthType

Optional depth of the output matrix.

Returns

GMat

The per-element scaled product of two matrices.

MulC(GMat, GScalar, DepthType)

Multiplies matrix by scalar.

public static GMat MulC(GMat src1, GScalar c, DepthType ddepth = DepthType.Default)

Parameters

src1 GMat

Input matrix.

c GScalar

Factor to be multiplied

ddepth DepthType

Optional depth of the output matrix.

Returns

GMat

The per-element scaled product of the matrix and the scale.

NV12toBGR(GMat, GMat)

Converts an image from NV12 (YUV420p) color space to BGR.

public static GMat NV12toBGR(GMat srcY, GMat srcUV)

Parameters

srcY GMat

Input image: 8-bit unsigned 1-channel

srcUV GMat

Input image: 8-bit unsigned 2-channel

Returns

GMat

Output image, 8-bit unsigned 3-channel

NV12toGray(GMat, GMat)

Converts an image from NV12 (YUV420p) color space to gray-scaled.

public static GMat NV12toGray(GMat srcY, GMat srcUV)

Parameters

srcY GMat

Input image: 8-bit unsigned 1-channel

srcUV GMat

Input image: 8-bit unsigned 2-channel

Returns

GMat

Output image, 8-bit unsigned 1-channel

NV12toRGB(GMat, GMat)

Converts an image from NV12 (YUV420p) color space to RGB.

public static GMat NV12toRGB(GMat srcY, GMat srcUV)

Parameters

srcY GMat

Input image: 8-bit unsigned 1-channel

srcUV GMat

Input image: 8-bit unsigned 2-channel

Returns

GMat

Output image, 8-bit unsigned 3-channel

NormInf(GMat)

Calculates the absolute infinite norm of a matrix.

public static GScalar NormInf(GMat src)

Parameters

src GMat

Input matrix.

Returns

GScalar

The absolute infinite norm of a matrix.

NormL1(GMat)

Calculates the absolute L1 norm of a matrix.

public static GScalar NormL1(GMat src)

Parameters

src GMat

Tnput matrix.

Returns

GScalar

The absolute L1 norm of a matrix.

NormL2(GMat)

Calculates the absolute L2 norm of a matrix.

public static GScalar NormL2(GMat src)

Parameters

src GMat

Input matrix.

Returns

GScalar

The absolute L2 norm of a matrix.

Normalize(GMat, double, double, NormType, DepthType)

Normalizes the norm or value range of an array

public static GMat Normalize(GMat src, double alpha, double beta, NormType normType = NormType.L2, DepthType dType = DepthType.Default)

Parameters

src GMat

The input array

alpha double

Norm value to normalize to or the lower range boundary in case of the range normalization.

beta double

Upper range boundary in case of the range normalization; it is not used for the norm normalization.

normType NormType

The normalization type

dType DepthType

Optional depth type for the returned array

Returns

GMat

The normalized output array

Phase(GMat, GMat, bool)

Calculates the rotation angle of 2D vectors.

public static GMat Phase(GMat x, GMat y, bool angleInDegrees)

Parameters

x GMat

Input floating-point array of x-coordinates of 2D vectors.

y GMat

Input array of y-coordinates of 2D vectors; it must have the same size and the same type as x.

angleInDegrees bool

When true, the function calculates the angle in degrees, otherwise, they are measured in radians.

Returns

GMat

Array of vector angles; it has the same size and same type as x.

PolarToCart(GMat, GMat, bool)

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

public static Tuple<GMat, GMat> PolarToCart(GMat magnitude, GMat angle, bool angleInDegrees = false)

Parameters

magnitude GMat

Input floating-point CV_32FC1 matrix (1xN) of magnitudes of 2D vectors

angle GMat

Input floating-point CV_32FC1 matrix (1xN) of angles of 2D vectors.

angleInDegrees bool

When true, the input angles are measured in degrees, otherwise, they are measured in radians.

Returns

Tuple<GMat, GMat>

The first GMat contains the X coordinates, the second GMat contains the Y coordinates.

RGB2Gray(GMat)

Converts an image from RGB color space to gray-scaled.

public static GMat RGB2Gray(GMat src)

Parameters

src GMat

input image: 8-bit unsigned 3-channel image.

Returns

GMat

Output image, 8-bit unsigned 1-channel image.

RGB2Gray(GMat, float, float, float)

Converts an image from RGB color space to gray-scaled.

public static GMat RGB2Gray(GMat src, float rY, float gY, float bY)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel image.

rY float

Float multiplier for R channel.

gY float

Float multiplier for G channel.

bY float

Float multiplier for B channel.

Returns

GMat

Output image, 8-bit unsigned 1-channel image.

RGB2HSV(GMat)

Converts an image from RGB color space to HSV.

public static GMat RGB2HSV(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel

Returns

GMat

Output image, 8-bit unsigned 3-channel

RGB2I420(GMat)

Converts an image from RGB color space to I420 color space.

public static GMat RGB2I420(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel

Returns

GMat

Output image, 8-bit unsigned 1-channel

RGB2Lab(GMat)

Converts an image from RGB color space to Lab color space.

public static GMat RGB2Lab(GMat src)

Parameters

src GMat

input image: 8-bit unsigned 3-channel.

Returns

GMat

Output image, 8-bit unsigned 3-channel

RGB2YUV(GMat)

Converts an image from RGB color space to YUV color space.

public static GMat RGB2YUV(GMat src)

Parameters

src GMat

input image: 8-bit unsigned 3-channel image.

Returns

GMat

Output image, 8-bit unsigned 3-channel image

RGB2YUV422(GMat)

Converts an image from RGB color space to YUV422.

public static GMat RGB2YUV422(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel

Returns

GMat

Output image, 8-bit unsigned 2-channel

Remap(GMat, Mat, Mat, Inter, BorderType, MCvScalar)

Applies a generic geometrical transformation to an image.

public static GMat Remap(GMat src, Mat map1, Mat map2, Inter interpolation, BorderType borderMode = BorderType.Constant, MCvScalar borderValue = default)

Parameters

src GMat

Source image.

map1 Mat

The first map of either (x,y) points or just x values having the type CV_16SC2, CV_32FC1, or CV_32FC2.

map2 Mat

The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively.

interpolation Inter

Interpolation method

borderMode BorderType

Pixel extrapolation method

borderValue MCvScalar

Value used in case of a constant border. By default, it is 0.

Returns

GMat

The transformed image.

Resize(GMat, Size, double, double, Inter)

Resizes an image.

public static GMat Resize(GMat src, Size dsize, double fx = 0, double fy = 0, Inter interpolation = Inter.Linear)

Parameters

src GMat

Input image.

dsize Size

Output image size

fx double

Scale factor along the horizontal axis

fy double

Scale factor along the vertical axis

interpolation Inter

Interpolation method

Returns

GMat

The resized image

Select(GMat, GMat, GMat)

Select values from either first or second of input matrices by given mask. The function set to the output matrix either the value from the first input matrix if corresponding value of mask matrix is 255, or value from the second input matrix (if value of mask matrix set to 0).

public static GMat Select(GMat src1, GMat src2, GMat mask)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix.

mask GMat

Mask input matrix.

Returns

GMat

Select result from either first or second of input matrices by given mask.

SepFilter(GMat, DepthType, Mat, Mat, Point, MCvScalar, BorderType, MCvScalar)

Applies a separable linear filter to a matrix(image).

public static GMat SepFilter(GMat src, DepthType ddepth, Mat kernelX, Mat kernelY, Point anchor, MCvScalar delta, BorderType borderType = BorderType.Default, MCvScalar borderValue = default)

Parameters

src GMat

Source image.

ddepth DepthType

Desired depth of the destination image

kernelX Mat

Coefficients for filtering each row.

kernelY Mat

Coefficients for filtering each column.

anchor Point

Anchor position within the kernel. The default value (−1,−1) means that the anchor is at the kernel center.

delta MCvScalar

Value added to the filtered results before storing them.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of constant border type

Returns

GMat

Result of applying the filter

Sobel(GMat, DepthType, int, int, int, double, double, BorderType, MCvScalar)

Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.

public static GMat Sobel(GMat src, DepthType ddepth, int dx, int dy, int ksize = 3, double scale = 1, double delta = 0, BorderType borderType = BorderType.Default, MCvScalar borderValue = default)

Parameters

src GMat

Input image.

ddepth DepthType

Output image depth。

dx int

Order of the derivative x.

dy int

Order of the derivative y.

ksize int

Size of the extended Sobel kernel; it must be odd.

scale double

Optional scale factor for the computed derivative values; by default, no scaling is applied

delta double

Optional delta value that is added to the results prior to storing them in dst.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of constant border type

Returns

GMat

The sobel filtered image

SobelXY(GMat, DepthType, int, int, double, double, BorderType, MCvScalar)

Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.

public static Tuple<GMat, GMat> SobelXY(GMat src, DepthType ddepth, int order, int ksize = 3, double scale = 1, double delta = 0, BorderType borderType = BorderType.Default, MCvScalar borderValue = default)

Parameters

src GMat

Input image

ddepth DepthType

Output image depth

order int

Order of the derivatives

ksize int

Size of the extended Sobel kernel; it must be odd.

scale double

Optional scale factor for the computed derivative values; by default, no scaling is applied

delta double

Optional delta value that is added to the results prior to storing them in dst.

borderType BorderType

Pixel extrapolation method

borderValue MCvScalar

Border value in case of constant border type

Returns

Tuple<GMat, GMat>

First returned matrix correspond to dx derivative while the second one to dy

Split3(GMat)

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

public static Tuple<GMat, GMat, GMat> Split3(GMat src)

Parameters

src GMat

Input CV_8UC3 matrix.

Returns

Tuple<GMat, GMat, GMat>

3 single-channel matrices.

Split4(GMat)

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

public static Tuple<GMat, GMat, GMat, GMat> Split4(GMat src)

Parameters

src GMat

Input CV_8UC4 matrix.

Returns

Tuple<GMat, GMat, GMat, GMat>

4 single-channel matrices.

Sqrt(GMat)

Calculates a square root of each input array element. In case of multi-channel arrays, each channel is processed independently.

public static GMat Sqrt(GMat src)

Parameters

src GMat

Input floating-point array.

Returns

GMat

Output array of the same size and type as src.

Stereo(GMat, GMat, StereoOutputFormat)

Computes disparity/depth map for the specified stereo-pair. The function computes disparity or depth map depending on passed StereoOutputFormat argument.

public static GMat Stereo(GMat left, GMat right, StereoOutputFormat of)

Parameters

left GMat

8-bit single-channel left image of CV_8UC1 type.

right GMat

8-bit single-channel right image of CV_8UC1 type.

of StereoOutputFormat

enum to specified output kind: depth or disparity and corresponding type

Returns

GMat

disparity/depth map for the specified stereo-pair

Sub(GMat, GMat, DepthType)

Calculates the per-element difference between two matrices.

public static GMat Sub(GMat src1, GMat src2, DepthType ddepth = DepthType.Default)

Parameters

src1 GMat

First input matrix.

src2 GMat

Second input matrix.

ddepth DepthType

Optional depth of the output matrix.

Returns

GMat

The per-element difference between two matrices.

SubC(GMat, GScalar, DepthType)

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

public static GMat SubC(GMat src, GScalar c, DepthType ddepth = DepthType.Default)

Parameters

src GMat

First input matrix.

c GScalar

Scalar value to subtracted.

ddepth DepthType

Optional depth of the output matrix.

Returns

GMat

The per-element difference between matrix and given scalar.

SubRC(GScalar, GMat, DepthType)

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

public static GMat SubRC(GScalar c, GMat src, DepthType ddepth = DepthType.Default)

Parameters

c GScalar

Scalar value to subtract from

src GMat

Input matrix to be subtracted.

ddepth DepthType

Optional depth of the output matrix.

Returns

GMat

Per-element difference between given scalar and the matrix.

Sum(GMat)

Calculates sum of all matrix elements.

public static GScalar Sum(GMat src)

Parameters

src GMat

Input matrix.

Returns

GScalar

Sum of all matrix elements, independently for each channel.

Threshold(GMat, GScalar, GScalar, ThresholdType)

Applies a fixed-level threshold to each matrix element.

public static GMat Threshold(GMat src, GScalar thresh, GScalar maxval, ThresholdType type)

Parameters

src GMat

Input matrix

thresh GScalar

Threshold value.

maxval GScalar

Maximum value to use

type ThresholdType

Thresholding type

Returns

GMat

The thresholded image

Transpose(GMat)

Transposes a matrix.

public static GMat Transpose(GMat src)

Parameters

src GMat

Source matrix

Returns

GMat

The transposed matrix.

WarpAffine(GMat, Mat, Size, Inter, Warp, BorderType, MCvScalar)

Applies an affine transformation to an image.

public static GMat WarpAffine(GMat src, Mat m, Size dsize, Inter interMethod = Inter.Linear, Warp warpMethod = Warp.Default, BorderType borderMode = BorderType.Constant, MCvScalar borderValue = default)

Parameters

src GMat

Source image

m Mat

2x3 transformation matrix

dsize Size

Size of the output image.

interMethod Inter

Interpolation method

warpMethod Warp

Warp method

borderMode BorderType

Pixel extrapolation method

borderValue MCvScalar

A value used to fill outliers

Returns

GMat

The transformed image.

WarpPerspective(GMat, Mat, Size, Inter, Warp, BorderType, MCvScalar)

Applies a perspective transformation to an image.

public static GMat WarpPerspective(GMat src, Mat m, Size dsize, Inter interMethod = Inter.Linear, Warp warpMethod = Warp.Default, BorderType borderMode = BorderType.Constant, MCvScalar borderValue = default)

Parameters

src GMat

Source image

m Mat

3x3 transformation matrix

dsize Size

Size of the output image.

interMethod Inter

Interpolation method

warpMethod Warp

Warp method

borderMode BorderType

Pixel extrapolation method

borderValue MCvScalar

A value used to fill outliers

Returns

GMat

The transformed image.

YUV2BGR(GMat)

Converts an image from YUV color space to BGR color space.

public static GMat YUV2BGR(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel.

Returns

GMat

Output image, 8-bit unsigned 3-channel.

YUV2RGB(GMat)

Converts an image from YUV color space to RGB.

public static GMat YUV2RGB(GMat src)

Parameters

src GMat

Input image: 8-bit unsigned 3-channel

Returns

GMat

Output image, 8-bit unsigned 3-channel