Table of Contents

Class GpuMat

Namespace
Emgu.CV.Cuda
Assembly
Emgu.CV.dll

A GpuMat, use the generic version if possible. The non generic version is good for use as buffer in stream calls.

public class GpuMat : UnmanagedObject, IEquatable<GpuMat>, IInputOutputArray, IInputArrayOfArrays, IOutputArrayOfArrays, IOutputArray, IInputArray, IDisposable
Inheritance
GpuMat
Implements
Derived
Inherited Members
Extension Methods

Constructors

GpuMat()

Create an empty GpuMat

public GpuMat()

GpuMat(GpuMat, Range, Range)

Create a GpuMat from the specific region of mat. The data is shared between the two GpuMat

public GpuMat(GpuMat mat, Range rowRange, Range colRange)

Parameters

mat GpuMat

The matrix where the region is extracted from

rowRange Range

The row range.

colRange Range

The column range.

GpuMat(IInputArray)

Create a GpuMat from an CvArray of the same depth type

public GpuMat(IInputArray arr)

Parameters

arr IInputArray

The CvArray to be converted to GpuMat

GpuMat(int, int, DepthType, int, bool)

Create a GpuMat of the specified size

public GpuMat(int rows, int cols, DepthType depthType, int channels, bool continuous = false)

Parameters

rows int

The number of rows (height)

cols int

The number of columns (width)

depthType DepthType

The type of depth

channels int

The number of channels

continuous bool

Indicates if the data should be continuous

GpuMat(int, int, DepthType, int, nint, int)

Create a GpuMat pointing to user-allocated data

public GpuMat(int rows, int cols, DepthType depthType, int channels, nint data, int step = 0)

Parameters

rows int

The number of rows (height)

cols int

The number of columns (width)

depthType DepthType

The type of depth

channels int

The number of channels

data nint

User allocated data

step int

Use 0 for auto matically calculated step. Or specify the data step here.

Properties

Depth

Depth type

public DepthType Depth { get; }

Property Value

DepthType

IsContinuous

True if the data is continues

public bool IsContinuous { get; }

Property Value

bool

IsEmpty

True if the matrix is empty

public bool IsEmpty { get; }

Property Value

bool

NumberOfChannels

Number of channels

public int NumberOfChannels { get; }

Property Value

int

Size

Get the GpuMat size: width == number of columns, height == number of rows

public Size Size { get; }

Property Value

Size

Type

Get the type of the GpuMat

public int Type { get; }

Property Value

int

Methods

Clone()

Make a clone of the GpuMat

public object Clone()

Returns

object

A clone of the GPU Mat

Col(int)

Returns a GpuMat corresponding to the ith column of the GpuMat. The data is shared with the current GpuMat.

public GpuMat Col(int i)

Parameters

i int

The column to be extracted

Returns

GpuMat

The ith column of the GpuMat

Remarks

The parent GpuMat should never be released before the returned GpuMat that represent the subregion

ColRange(int, int)

Returns a GpuMat corresponding to the [start end) columns of the GpuMat. The data is shared with the current GpuMat.

public GpuMat ColRange(int start, int end)

Parameters

start int

The inclusive stating column to be extracted

end int

The exclusive ending column to be extracted

Returns

GpuMat

The [start end) columns of the GpuMat

Remarks

The parent GpuMat should never be released before the returned GpuMat that represent the subregion

ConvertTo(IOutputArray, DepthType, double, double, Stream)

This function has several different purposes and thus has several synonyms. It copies one GpuMat to another with optional scaling, which is performed first, and/or optional type conversion, performed after: dst(I)=src(I)*scale + (shift,shift,...) All the channels of multi-channel GpuMats are processed independently. The type conversion is done with rounding and saturation, that is if a result of scaling + conversion can not be represented exactly by a value of destination GpuMat element type, it is set to the nearest representable value on the real axis. In case of scale=1, shift=0 no prescaling is done. This is a specially optimized case and it has the appropriate convertTo synonym.

public void ConvertTo(IOutputArray dst, DepthType rtype, double scale = 1, double shift = 0, Stream stream = null)

Parameters

dst IOutputArray

Destination GpuMat

rtype DepthType

Result type

scale double

Scale factor

shift double

Value added to the scaled source GpuMat elements

stream Stream

Use a Stream to call the function asynchronously (non-blocking) or IntPtr.Zero to call the function synchronously (blocking).

CopyTo(IOutputArray, IInputArray, Stream)

Copy the source GpuMat to destination GpuMat, using an optional mask.

public void CopyTo(IOutputArray dst, IInputArray mask = null, Stream stream = null)

Parameters

dst IOutputArray

The output array to be copied to

mask IInputArray

The optional mask, use IntPtr.Zero if not needed.

stream Stream

Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).

Create(int, int, DepthType, int)

allocates new GpuMat data unless the GpuMat already has specified size and type

public void Create(int rows, int cols, DepthType depthType, int channels)

Parameters

rows int

The number of rows

cols int

The number of cols

depthType DepthType

The depth type

channels int

The number of channels.

DisposeObject()

Release the unmanaged memory associated with this GpuMat

protected override void DisposeObject()

Download(IOutputArray, Stream)

Downloads data from device to host memory.

public void Download(IOutputArray arr, Stream stream = null)

Parameters

arr IOutputArray

The destination CvArray where the GpuMat data will be downloaded to.

stream Stream

Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).

Equals(GpuMat)

Returns true if the two GpuMat equals

public bool Equals(GpuMat other)

Parameters

other GpuMat

The other GpuMat to be compares with

Returns

bool

True if the two GpuMat equals

GetData(bool)

Get a copy of the data values as an array

public Array GetData(bool jagged = true)

Parameters

jagged bool

If 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

GetOutputArray()

Pointer to the OutputArray

public OutputArray GetOutputArray()

Returns

OutputArray

The output array

MergeFrom(GpuMat[], Stream)

Makes multi-channel array out of several single-channel arrays

public void MergeFrom(GpuMat[] gpuMats, Stream stream = null)

Parameters

gpuMats GpuMat[]

An array of single channel GpuMat where each item in the array represent a single channel of the GpuMat

stream Stream

Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).

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 shape of GpuMat without copying data.

public GpuMat Reshape(int newCn, int newRows = 0)

Parameters

newCn int

New number of channels. newCn = 0 means that the number of channels remains unchanged.

newRows int

New number of rows. newRows = 0 means that the number of rows remains unchanged unless it needs to be changed according to newCn value.

Returns

GpuMat

A GpuMat of different shape

Row(int)

Returns a GpuMat corresponding to the ith row of the GpuMat. The data is shared with the current GpuMat.

public GpuMat Row(int i)

Parameters

i int

The row to be extracted

Returns

GpuMat

The ith row of the GpuMat

Remarks

The parent GpuMat should never be released before the returned GpuMat that represent the subregion

RowRange(int, int)

Returns a GpuMat corresponding to the [start end) rows of the GpuMat. The data is shared with the current GpuMat.

public GpuMat RowRange(int start, int end)

Parameters

start int

The inclusive stating row to be extracted

end int

The exclusive ending row to be extracted

Returns

GpuMat

The [start end) rows of the GpuMat

Remarks

The parent GpuMat should never be released before the returned GpuMat that represent the subregion

Save(string)

Save the GpuMat to a file

public void Save(string fileName)

Parameters

fileName string

The file name

SetTo(MCvScalar, IInputArray, Stream)

Copies scalar value to every selected element of the destination GpuMat: arr(I)=value if mask(I)!=0

public void SetTo(MCvScalar value, IInputArray mask = null, Stream stream = null)

Parameters

value MCvScalar

Fill value

mask IInputArray

Operation mask, 8-bit single channel GpuMat; specifies elements of destination GpuMat to be changed. Can be IntPtr.Zero if not used

stream Stream

Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).

Split(Stream)

Split current GpuMat into an array of single channel GpuMat where each element in the array represent a single channel of the original GpuMat

public GpuMat[] Split(Stream stream = null)

Parameters

stream Stream

Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).

Returns

GpuMat[]

An array of single channel GpuMat where each element
in the array represent a single channel of the original GpuMat

ToMat()

Convert the GpuMat to Mat

public Mat ToMat()

Returns

Mat

The Mat that contains the same data as this GpuMat

Upload(IInputArray, Stream)

Upload data to GpuMat

public void Upload(IInputArray arr, Stream stream = null)

Parameters

arr IInputArray

The CvArray to be uploaded to GpuMat

stream Stream

Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).