OpenCV for Unity 3.0.0
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.12.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.UnityUtils.Helper.Source2MatHelperUtils Class Reference

Static Public Member Functions

static Mat ApplyMatTransformations (Mat inputMat, Mat rotated90Mat, bool flipVertical, bool flipHorizontal)
 Apply Mat transformations based on IMatTransformationProvider settings.
 
static int Channels (Source2MatHelperColorFormat type)
 Gets the number of channels for the specified color format.
 
static int ColorConversionCodes (Source2MatHelperColorFormat srcType, Source2MatHelperColorFormat dstType)
 Gets the OpenCV color conversion code needed for converting between two color formats.
 

Member Function Documentation

◆ ApplyMatTransformations()

static Mat OpenCVForUnity.UnityUtils.Helper.Source2MatHelperUtils.ApplyMatTransformations ( Mat inputMat,
Mat rotated90Mat,
bool flipVertical,
bool flipHorizontal )
static

Apply Mat transformations based on IMatTransformationProvider settings.

Parameters
inputMatInput mat to transform.
rotated90MatThe rotated Mat output. If null, no rotation will be performed. If not null, must have the same CVType as inputMat and dimensions swapped (width=height, height=width).
flipVerticalWhether to flip vertically.
flipHorizontalWhether to flip horizontally.
Returns
Transformed mat.

The rotated90Mat parameter must be pre-allocated with the correct dimensions and CVType to prevent any memory allocation during rotation. If rotated90Mat is null, the method will return inputMat without rotation.

◆ Channels()

static int OpenCVForUnity.UnityUtils.Helper.Source2MatHelperUtils.Channels ( Source2MatHelperColorFormat type)
static

Gets the number of channels for the specified color format.

Parameters
typeThe color format
Returns
Number of channels. Returns 1 for GRAY, 3 for RGB/BGR, 4 for RGBA/BGRA. Returns 4 for unknown formats.

Channel counts for each color format:

  • GRAY: 1 channel
  • RGB/BGR: 3 channels
  • RGBA/BGRA: 4 channels

◆ ColorConversionCodes()

static int OpenCVForUnity.UnityUtils.Helper.Source2MatHelperUtils.ColorConversionCodes ( Source2MatHelperColorFormat srcType,
Source2MatHelperColorFormat dstType )
static

Gets the OpenCV color conversion code needed for converting between two color formats.

Parameters
srcTypeThe source color format
dstTypeThe destination color format
Returns
OpenCV color conversion code. Returns -1 if conversion is not possible.

Supported color format conversions:

  • GRAY ⇔ RGB/BGR/RGBA/BGRA
  • RGB ⇔ GRAY/BGR/RGBA/BGRA
  • BGR ⇔ GRAY/RGB/RGBA/BGRA
  • RGBA ⇔ GRAY/RGB/BGR/BGRA
  • BGRA ⇔ GRAY/RGB/BGR/RGBA

The documentation for this class was generated from the following file: