Class UMat
The equivalent of cv::Mat, should only be used if you know what you are doing. In most case you should use the Matrix class instead
[JsonConverter(typeof(UMat.UMatJsonConverter))]
public class UMat : UnmanagedObject, IEquatable<UMat>, IInputOutputArray, IInputArrayOfArrays, IOutputArrayOfArrays, IOutputArray, IInputArray, IDisposable, ISerializable
- Inheritance
-
UMat
- Implements
- Inherited Members
- Extension Methods
Constructors
UMat(UMat, Range, Range)
Create a umat header for the specific ROI
public UMat(UMat umat, Range rowRange, Range colRange)
Parameters
umat
UMatThe umat where the new UMat header will share data from
rowRange
RangeThe region of interest
colRange
RangeThe region of interest
UMat(UMat, Rectangle)
Get the Umat header for the specific roi of the parent
public UMat(UMat parent, Rectangle roi)
Parameters
UMat(Usage)
Create an empty cv::UMat
public UMat(UMat.Usage usage = Usage.Default)
Parameters
UMat(Size, DepthType, int, Usage)
Create a umat of the specific type.
public UMat(Size size, DepthType type, int channels, UMat.Usage usage = Usage.Default)
Parameters
size
SizeSize of the UMat
type
DepthTypeMat element type
channels
intNumber of channels
usage
UMat.UsageAllocation Usage
UMat(int, int, DepthType, int, Usage)
Create a umat of the specific type.
public UMat(int rows, int cols, DepthType type, int channels, UMat.Usage usage = Usage.Default)
Parameters
rows
intNumber of rows in a 2D array.
cols
intNumber of columns in a 2D array.
type
DepthTypeMat element type
channels
intNumber of channels
usage
UMat.UsageAllocation Usage
UMat(SerializationInfo, StreamingContext)
Constructor used to deserialize runtime serialized object
public UMat(SerializationInfo info, StreamingContext context)
Parameters
info
SerializationInfoThe serialization info
context
StreamingContextThe streaming context
UMat(string, ImreadModes)
Read a UMat from file.
public UMat(string fileName, ImreadModes loadType)
Parameters
fileName
stringThe name of the file
loadType
ImreadModesThe read mode
Properties
Bytes
Get or Set the raw image data
public byte[] Bytes { get; set; }
Property Value
- byte[]
Cols
The number of columns
public int Cols { get; }
Property Value
Depth
Depth type
public DepthType Depth { get; }
Property Value
Dims
The matrix dimensionality
public int Dims { get; }
Property Value
ElementSize
The size of the elements in this matrix
public int ElementSize { get; }
Property Value
IsContinuous
True if the data is continues
public bool IsContinuous { get; }
Property Value
IsEmpty
True if the matrix is empty
public bool IsEmpty { get; }
Property Value
IsSubmatrix
True if the matrix is a submatrix of another matrix
public bool IsSubmatrix { get; }
Property Value
NumberOfChannels
Number of channels
public int NumberOfChannels { get; }
Property Value
Rows
The number of rows
public int Rows { get; }
Property Value
Size
The size of this matrix
public Size Size { get; }
Property Value
Total
The method returns the number of array elements (a number of pixels if the array represents an image)
public nint Total { get; }
Property Value
Methods
Clone()
Make a clone of the current UMat.
public UMat Clone()
Returns
- UMat
A clone of the current UMat.
Col(int)
Creates a matrix header for the specified matrix column.
public UMat Col(int x)
Parameters
x
intA 0-based column index.
Returns
- UMat
A matrix header for the specified matrix column.
ConvertTo(IOutputArray, DepthType, double, double)
Converts an array to another data type with optional scaling.
public void ConvertTo(IOutputArray m, DepthType rtype, double alpha = 1, double beta = 0)
Parameters
m
IOutputArrayOutput matrix; if it does not have a proper size or type before the operation, it is reallocated.
rtype
DepthTypeDesired output matrix type or, rather, the depth since the number of channels are the same as the input has; if rtype is negative, the output matrix will have the same type as the input.
alpha
doubleOptional scale factor.
beta
doubleOptional delta added to the scaled values.
CopyTo(IOutputArray, IInputArray)
Copy the data in this umat to the other mat
public void CopyTo(IOutputArray m, IInputArray mask = null)
Parameters
m
IOutputArrayThe input array to copy to
mask
IInputArrayOperation mask. Its non-zero elements indicate which matrix elements need to be copied.
CopyTo<T>(T[])
Copy data from this Mat to the managed array
public void CopyTo<T>(T[] data)
Parameters
data
T[]The managed array where data will be copied to.
Type Parameters
T
The type of managed data array
Create(int, int, DepthType, int, Usage)
Allocates new array data if needed.
public void Create(int rows, int cols, DepthType type, int channels, UMat.Usage usage = Usage.Default)
Parameters
rows
intNew number of rows.
cols
intNew number of columns.
type
DepthTypeNew matrix element depth type.
channels
intNew matrix number of channels
usage
UMat.UsageAllocation Usage
DeserializeObjectData(SerializationInfo, StreamingContext)
A function used for runtime deserailization of the object
protected virtual void DeserializeObjectData(SerializationInfo info, StreamingContext context)
Parameters
info
SerializationInfoSerialization info
context
StreamingContextStreaming context
DisposeObject()
Release all the unmanaged memory associated with this object.
protected override void DisposeObject()
Dot(IInputArray)
Computes the dot product of two mats
public double Dot(IInputArray mat)
Parameters
mat
IInputArrayThe matrix to compute dot product with
Returns
- double
The dot product
Equals(UMat)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(UMat other)
Parameters
other
UMatAn object to compare with this object.
Returns
- bool
true if the current object is equal to the
other
parameter; otherwise, false.
GetData(bool)
Get a copy of the data values as an array
public Array GetData(bool jagged = true)
Parameters
jagged
boolIf true, a jagged array will returned. Otherwise it will return a regular array.
Returns
- Array
a copy of the data values as an array
GetInputArray()
Pointer to the InputArray
public InputArray GetInputArray()
Returns
- InputArray
The input array
GetInputOutputArray()
Pointer to the InputOutputArray
public InputOutputArray GetInputOutputArray()
Returns
- InputOutputArray
The input output array
GetMat(AccessType)
Return the Mat representation of the UMat
public Mat GetMat(AccessType access)
Parameters
access
AccessTypeThe access type
Returns
- Mat
The Mat representation of the UMat
GetObjectData(SerializationInfo, StreamingContext)
A function used for runtime serialization of the object
public void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
info
SerializationInfoSerialization info
context
StreamingContextstreaming context
GetOutputArray()
Pointer to the OutputArray
public OutputArray GetOutputArray()
Returns
- OutputArray
The output array
MinMax(out double[], out double[], out Point[], out Point[])
Returns the min / max location and values for the image
public void MinMax(out double[] minValues, out double[] maxValues, out Point[] minLocations, out Point[] maxLocations)
Parameters
minValues
double[]The minimum values for each channel
maxValues
double[]The maximum values for each channel
minLocations
Point[]The minimum locations for each channel
maxLocations
Point[]The maximum locations for each channel
Reshape(int, int)
Changes the shape and/or the number of channels of a 2D matrix without copying the data.
public UMat Reshape(int cn, int rows = 0)
Parameters
cn
intNew number of channels. If the parameter is 0, the number of channels remains the same.
rows
intNew number of rows. If the parameter is 0, the number of rows remains the same.
Returns
- UMat
A new mat header that has different shape
Row(int)
Creates a matrix header for the specified matrix row.
public UMat Row(int y)
Parameters
y
intA 0-based row index.
Returns
- UMat
A matrix header for the specified matrix row.
Save(string)
Save this image to the specific file.
public void Save(string fileName)
Parameters
fileName
stringThe name of the file to be saved to
Remarks
The image format is chosen depending on the filename extension, see cvLoadImage. Only 8-bit single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use cvCvtScale and cvCvtColor to convert it before saving, or use universal cvSave to save the image to XML or YAML format.
SetTo(IInputArray, IInputArray)
Sets all or some of the array elements to the specified value.
public void SetTo(IInputArray value, IInputArray mask = null)
Parameters
value
IInputArrayAssigned scalar converted to the actual array type.
mask
IInputArrayOperation mask of the same size as the umat.
SetTo(MCvScalar, IInputArray)
Sets all or some of the array elements to the specified value.
public void SetTo(MCvScalar value, IInputArray mask = null)
Parameters
value
MCvScalarAssigned scalar value.
mask
IInputArrayOperation mask of the same size as the umat.
SetTo<T>(T[])
Copy data from managed array to this Mat
public void SetTo<T>(T[] data)
Parameters
data
T[]The managed array where data will be copied from
Type Parameters
T
The type of managed data array
Split()
Split current Image into an array of gray scale images where each element in the array represent a single color channel of the original image
public UMat[] Split()
Returns
- UMat[]
An array of gray scale images where each element
in the array represent a single color channel of the original image
ToImage<TColor, TDepth>()
Convert this Mat to Image
public Image<TColor, TDepth> ToImage<TColor, TDepth>() where TColor : struct, IColor where TDepth : new()
Returns
- Image<TColor, TDepth>
The image
Type Parameters
TColor
The type of Color
TDepth
The type of Depth
Operators
operator +(MCvScalar, UMat)
Element wise add mat
with value
public static UMat operator +(MCvScalar value, UMat mat)
Parameters
Returns
- UMat
The images plus the color
operator +(UMat, MCvScalar)
Element wise add mat
with value
public static UMat operator +(UMat mat, MCvScalar value)
Parameters
Returns
- UMat
The mat plus the value
operator +(UMat, UMat)
Element wise add mat1
with mat2
public static UMat operator +(UMat mat1, UMat mat2)
Parameters
Returns
- UMat
The sum of the two images
operator +(UMat, double)
Element wise add mat
with value
public static UMat operator +(UMat mat, double value)
Parameters
Returns
- UMat
The images plus the value
operator +(double, UMat)
Element wise add mat1
with value
public static UMat operator +(double value, UMat mat1)
Parameters
Returns
- UMat
The mat plus the value
operator &(MCvScalar, UMat)
Perform an element wise AND operation using a mat and a scalar
public static UMat operator &(MCvScalar val, UMat mat1)
Parameters
Returns
- UMat
The result of the AND operation
operator &(UMat, MCvScalar)
Perform an element wise AND operation using a mat and a scalar
public static UMat operator &(UMat mat1, MCvScalar val)
Parameters
Returns
- UMat
The result of the AND operation
operator &(UMat, UMat)
Perform an element wise AND operation on the two mats
public static UMat operator &(UMat mat1, UMat mat2)
Parameters
Returns
- UMat
The result of the AND operation
operator &(UMat, double)
Perform an element wise AND operation using a mat and a scalar
public static UMat operator &(UMat mat1, double val)
Parameters
Returns
- UMat
The result of the AND operation
operator &(double, UMat)
Perform an element wise AND operation using a mat and a color
public static UMat operator &(double val, UMat mat1)
Parameters
Returns
- UMat
The result of the AND operation
operator |(MCvScalar, UMat)
Perform an binary OR operation with some scalar
public static UMat operator |(MCvScalar val, UMat mat1)
Parameters
Returns
- UMat
The result of the OR operation
operator |(UMat, MCvScalar)
Perform an binary OR operation with some scalar
public static UMat operator |(UMat mat1, MCvScalar val)
Parameters
Returns
- UMat
The result of the OR operation
operator |(UMat, UMat)
Perform an element wise OR operation with another mat and return the result
public static UMat operator |(UMat mat1, UMat mat2)
Parameters
mat1
UMatThe first mat to apply bitwise OR operation
mat2
UMatThe second mat to apply bitwise OR operation
Returns
- UMat
The result of the OR operation
operator |(UMat, double)
Perform an binary OR operation with some value
public static UMat operator |(UMat mat1, double val)
Parameters
Returns
- UMat
The result of the OR operation
operator |(double, UMat)
Perform an binary OR operation with some color
public static UMat operator |(double val, UMat mat1)
Parameters
Returns
- UMat
The result of the OR operation
operator /(UMat, double)
mat
/ scale
public static UMat operator /(UMat mat, double scale)
Parameters
Returns
- UMat
mat
/scale
operator /(double, UMat)
scale
/ mat
public static UMat operator /(double scale, UMat mat)
Parameters
Returns
- UMat
scale
/mat
operator *(UMat, double)
mat
* scale
public static UMat operator *(UMat mat, double scale)
Parameters
Returns
- UMat
mat
*scale
operator *(double, UMat)
scale
*mat
public static UMat operator *(double scale, UMat mat)
Parameters
Returns
- UMat
scale
*mat
operator ~(UMat)
Compute the complement Mat
public static UMat operator ~(UMat mat)
Parameters
mat
UMatThe mat to be inverted
Returns
- UMat
The complement image
operator -(MCvScalar, UMat)
Element wise subtract value from the current mat
public static UMat operator -(MCvScalar value, UMat mat)
Parameters
Returns
- UMat
value
-mat
operator -(UMat, MCvScalar)
Element wise subtract another mat from the current mat
public static UMat operator -(UMat mat, MCvScalar value)
Parameters
Returns
- UMat
The result of element wise subtracting
value
frommat
operator -(UMat, UMat)
Element wise subtract another mat from the current mat
public static UMat operator -(UMat mat1, UMat mat2)
Parameters
Returns
- UMat
The result of element wise subtracting img2 from
mat1
operator -(UMat, double)
Element wise subtract value from the current mat
public static UMat operator -(UMat mat, double value)
Parameters
Returns
- UMat
mat
-value
operator -(double, UMat)
value
- mat
public static UMat operator -(double value, UMat mat)
Parameters
Returns
- UMat
value
-mat