Table of Contents

Class CvArray<TDepth>

Namespace
Emgu.CV
Assembly
Emgu.CV.dll

Wrapped CvArr

public abstract class CvArray<TDepth> : UnmanagedObject, IXmlSerializable, IInputOutputArray, IInputArrayOfArrays, IOutputArrayOfArrays, IOutputArray, IInputArray, IDisposable, ISerializable where TDepth : new()

Type Parameters

TDepth

The type of elements in this CvArray

Inheritance
CvArray<TDepth>
Implements
IXmlSerializable
Derived
Inherited Members
Extension Methods

Constructors

CvArray()

protected CvArray()

Fields

_cvMat

The Mat header that represent this CvArr

protected Mat _cvMat

Field Value

Mat

_dataHandle

The pinned GCHandle to _array;

protected GCHandle _dataHandle

Field Value

GCHandle

Properties

Bytes

Get or Set an Array of bytes that represent the data in this array

public byte[] Bytes { get; set; }

Property Value

byte[]

Remarks

Should only be used for serialization & deserialization

Cols

The number of cols for this array

public int Cols { get; }

Property Value

int

Height

Get the height (Rows) of the cvArray. If ROI is set, the height of the ROI

public int Height { get; }

Property Value

int

ManagedArray

Get the underneath managed array

public abstract Array ManagedArray { get; set; }

Property Value

Array

Mat

Get the Mat header that represent this CvArr

public Mat Mat { get; }

Property Value

Mat

Norm

The norm of this Array

public double Norm { get; }

Property Value

double

NumberOfChannels

Get the number of channels of the array

public abstract int NumberOfChannels { get; }

Property Value

int

Ptr

The pointer to the internal structure

public nint Ptr { get; set; }

Property Value

nint

Rows

The number of rows for this array

public int Rows { get; }

Property Value

int

SerializationCompressionRatio

Get or set the Compression Ratio for serialization. A number between 0 - 9. 0 means no compression at all, while 9 means best compression

public int SerializationCompressionRatio { get; set; }

Property Value

int

Size

Get the size of the array

public virtual Size Size { get; }

Property Value

Size

SizeOfElement

Get the size of element in bytes

public static int SizeOfElement { get; }

Property Value

int

Trace

Sum of diagonal elements of the matrix

public MCvScalar Trace { get; }

Property Value

MCvScalar

Width

Get the width (Cols) of the cvArray. If ROI is set, the width of the ROI

public int Width { get; }

Property Value

int

Methods

AllocateData(int, int, int)

Allocate data for the array

protected abstract void AllocateData(int rows, int cols, int numberOfChannels)

Parameters

rows int

The number of rows

cols int

The number of columns

numberOfChannels int

The number of channels of this cvArray

CheckRange(double, double, ref Point)

Check that every array element is neither NaN nor +- inf. The functions also check that each value is between min and max. in the case of multi-channel arrays each channel is processed independently. If some values are out of range, position of the first outlier is stored in pos, and then the functions return false.

public bool CheckRange(double min, double max, ref Point position)

Parameters

min double

The inclusive lower boundary of valid values range

max double

The exclusive upper boundary of valid values range

position Point

This will be filled with the position of the first outlier

Returns

bool

True if all values are in range

CopyTo(CvArray<TDepth>)

Copy the current array to destination

public void CopyTo(CvArray<TDepth> destination)

Parameters

destination CvArray<TDepth>

The destination Array

DeserializeObjectData(SerializationInfo, StreamingContext)

A function used for runtime deserailization of the object

protected virtual void DeserializeObjectData(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

Serialization info

context StreamingContext

Streaming context

DisposeObject()

Free the _dataHandle if it is set

protected override void DisposeObject()

DotProduct(CvArray<TDepth>)

Calculates and returns the Euclidean dot product of two arrays. src1 dot src2 = sumI(src1(I)*src2(I))

public double DotProduct(CvArray<TDepth> otherArray)

Parameters

otherArray CvArray<TDepth>

The other Array to apply dot product with

Returns

double

src1 dot src2

Remarks

In case of multiple channel arrays the results for all channels are accumulated. In particular, cvDotProduct(a,a), where a is a complex vector, will return ||a||^2. The function can process multi-dimensional arrays, row by row, layer by layer and so on.

GetInputArray()

The unmanaged pointer to the input array.

public InputArray GetInputArray()

Returns

InputArray

The input array

GetInputOutputArray()

The unmanaged pointer to the input output array.

public InputOutputArray GetInputOutputArray()

Returns

InputOutputArray

The input output array

GetObjectData(SerializationInfo, StreamingContext)

A function used for runtime serialization of the object

public virtual void GetObjectData(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

Serialization info

context StreamingContext

Streaming context

GetOutputArray()

The unmanaged pointer to the output array.

public OutputArray GetOutputArray()

Returns

OutputArray

The output array

GetSchema()

Get the xml schema

public XmlSchema GetSchema()

Returns

XmlSchema

The xml schema

ReadXml(XmlReader)

Function to call when deserializing this object from XML

public virtual void ReadXml(XmlReader reader)

Parameters

reader XmlReader

The xml reader

Reduce<TOtherDepth>(CvArray<TOtherDepth>, ReduceDimension, ReduceType)

Reduces matrix to a vector by treating the matrix rows/columns as a set of 1D vectors and performing the specified operation on the vectors until a single row/column is obtained.

public void Reduce<TOtherDepth>(CvArray<TOtherDepth> array1D, ReduceDimension dim, ReduceType type) where TOtherDepth : new()

Parameters

array1D CvArray<TOtherDepth>

The destination single-row/single-column vector that accumulates somehow all the matrix rows/columns

dim ReduceDimension

The dimension index along which the matrix is reduce.

type ReduceType

The reduction operation type

Type Parameters

TOtherDepth

The type of depth of the reduced array

Remarks

The function can be used to compute horizontal and vertical projections of an raster image. In case of CV_REDUCE_SUM and CV_REDUCE_AVG the output may have a larger element bit-depth to preserve accuracy. And multi-channel arrays are also supported in these two reduction modes

Save(string)

Save the CvArray as image

public virtual void Save(string fileName)

Parameters

fileName string

The name of the image to save

SetIdentity()

Initialize the identity matrix

public void SetIdentity()

SetIdentity(MCvScalar)

Initializes scaled identity matrix

public void SetIdentity(MCvScalar value)

Parameters

value MCvScalar

The value on the diagonal

SetRandNormal(MCvScalar, MCvScalar)

Inplace fills Array with normally distributed random numbers

[ExposableMethod(Exposable = true)]
public void SetRandNormal(MCvScalar mean, MCvScalar std)

Parameters

mean MCvScalar

The mean value of random numbers

std MCvScalar

The standard deviation of random numbers

SetRandUniform(MCvScalar, MCvScalar)

Inplace fills Array with uniformly distributed random numbers

[ExposableMethod(Exposable = true)]
public void SetRandUniform(MCvScalar floorValue, MCvScalar ceilingValue)

Parameters

floorValue MCvScalar

the inclusive lower boundary of random numbers range

ceilingValue MCvScalar

the exclusive upper boundary of random numbers range

SetValue(MCvScalar, CvArray<byte>)

Set the element of the Array to value, using the specific mask

public void SetValue(MCvScalar value, CvArray<byte> mask = null)

Parameters

value MCvScalar

The value to be set

mask CvArray<byte>

The mask for the operation

SetValue(double, CvArray<byte>)

Set the element of the Array to value, using the specific mask

public void SetValue(double value, CvArray<byte> mask = null)

Parameters

value double

The value to be set

mask CvArray<byte>

The mask for the operation

SetZero()

Set the values to zero

public void SetZero()

ToUMat()

Get the umat representation of this mat

public UMat ToUMat()

Returns

UMat

The UMat

WriteXml(XmlWriter)

Function to call when serializing this object to XML

public virtual void WriteXml(XmlWriter writer)

Parameters

writer XmlWriter

The xml writer

_And(CvArray<TDepth>)

Inplace And operation with otherArray

public void _And(CvArray<TDepth> otherArray)

Parameters

otherArray CvArray<TDepth>

The other array to perform AND operation

_Max(CvArray<TDepth>)

Inplace elementwise maximize the current Array with other

public void _Max(CvArray<TDepth> other)

Parameters

other CvArray<TDepth>

The other array to be elementwise maximized with this array

_Max(double)

Inplace compute the elementwise maximum value with value

[ExposableMethod(Exposable = true, Category = "Logic")]
public void _Max(double value)

Parameters

value double

The value to be compare with

_Min(CvArray<TDepth>)

Inplace elementwise minimize the current Array with other

public void _Min(CvArray<TDepth> other)

Parameters

other CvArray<TDepth>

The other array to be elementwise minimized with this array

_Min(double)

Inplace compute the elementwise minimum value

[ExposableMethod(Exposable = true, Category = "Logic")]
public void _Min(double value)

Parameters

value double

The value to compare with

_Mul(CvArray<TDepth>)

Inplace elementwise multiply the current Array with src2

public void _Mul(CvArray<TDepth> src2)

Parameters

src2 CvArray<TDepth>

The other array to be elementwise multiplied with

_Mul(double)

Inplace multiply elements of the Array by scale

public void _Mul(double scale)

Parameters

scale double

The scale to be multiplyed

_Not()

Inplace compute the complement for all array elements

[ExposableMethod(Exposable = true, Category = "Logic")]
public void _Not()

_Or(CvArray<TDepth>)

Inplace Or operation with otherArray

public void _Or(CvArray<TDepth> otherArray)

Parameters

otherArray CvArray<TDepth>

The other array to perform OR operation