Show / Hide Table of Contents

Class SparseMat

Sparse matrix class.

Inheritance
System.Object
DisposableObject
DisposableCvObject
SparseMat
Implements
ICvPtrHolder
Inherited Members
DisposableCvObject.ptr
DisposableCvObject.CvPtr
DisposableObject.DataHandle
DisposableObject.IsDisposed
DisposableObject.IsEnabledDispose
DisposableObject.AllocatedMemory
DisposableObject.AllocatedMemorySize
DisposableObject.Dispose()
DisposableObject.Dispose(Boolean)
DisposableObject.DisposeManaged()
DisposableObject.AllocGCHandle(Object)
DisposableObject.AllocMemory(Int32)
DisposableObject.NotifyMemoryPressure(Int64)
DisposableObject.ThrowIfDisposed()
Namespace: OpenCvSharp
Assembly: OpenCvSharp.dll
Syntax
public class SparseMat : DisposableCvObject, ICvPtrHolder

Constructors

| Improve this Doc View Source

SparseMat()

Creates empty SparseMat

Declaration
public SparseMat()
| Improve this Doc View Source

SparseMat(IEnumerable<Int32>, MatType)

constructs n-dimensional sparse matrix

Declaration
public SparseMat(IEnumerable<int> sizes, MatType type)
Parameters
Type Name Description
IEnumerable<System.Int32> sizes

Array of integers specifying an n-dimensional array shape.

OpenCvSharp.MatType type

Array type. Use MatType.CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or MatType. CV_8UC(n), ..., CV_64FC(n) to create multi-channel matrices.

| Improve this Doc View Source

SparseMat(IntPtr)

Creates from native cv::SparseMat* pointer

Declaration
public SparseMat(IntPtr ptr)
Parameters
Type Name Description
IntPtr ptr
| Improve this Doc View Source

SparseMat(Mat)

converts old-style CvMat to the new matrix; the data is not copied by default

Declaration
public SparseMat(Mat m)
Parameters
Type Name Description
Mat m

cv::Mat object

Methods

| Improve this Doc View Source

AddRef()

manually increments the reference counter to the header.

Declaration
public void AddRef()
| Improve this Doc View Source

AssignFrom(Mat)

Assignment operator. equivalent to the corresponding constructor.

Declaration
public SparseMat AssignFrom(Mat m)
Parameters
Type Name Description
Mat m
Returns
Type Description
SparseMat
| Improve this Doc View Source

AssignFrom(SparseMat)

Assignment operator. This is O(1) operation, i.e. no data is copied

Declaration
public SparseMat AssignFrom(SparseMat m)
Parameters
Type Name Description
SparseMat m
Returns
Type Description
SparseMat
| Improve this Doc View Source

AssignTo(SparseMat, Nullable<MatType>)

not used now

Declaration
public void AssignTo(SparseMat m, MatType? type = null)
Parameters
Type Name Description
SparseMat m
System.Nullable<OpenCvSharp.MatType> type
| Improve this Doc View Source

Channels()

Returns the number of sparse matrix channels.

Declaration
public int Channels()
Returns
Type Description
System.Int32
| Improve this Doc View Source

Clear()

sets all the sparse matrix elements to 0, which means clearing the hash table.

Declaration
public void Clear()
| Improve this Doc View Source

Clone()

creates full copy of the matrix

Declaration
public SparseMat Clone()
Returns
Type Description
SparseMat
| Improve this Doc View Source

ConvertTo(Mat, MatType, Double, Double)

converts sparse matrix to dense n-dim matrix with optional type conversion and scaling.

Declaration
public void ConvertTo(Mat m, MatType rtype, double alpha = 1, double beta = 0)
Parameters
Type Name Description
Mat m
OpenCvSharp.MatType rtype

The output matrix data type. When it is =-1, the output array will have the same data type as (*this)

System.Double alpha

The scale factor

System.Double beta

The optional delta added to the scaled values before the conversion

| Improve this Doc View Source

ConvertTo(SparseMat, MatType, Double)

multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type

Declaration
public void ConvertTo(SparseMat m, MatType rtype, double alpha = 1)
Parameters
Type Name Description
SparseMat m
OpenCvSharp.MatType rtype
System.Double alpha
| Improve this Doc View Source

CopyTo(Mat)

converts sparse matrix to dense matrix.

Declaration
public void CopyTo(Mat m)
Parameters
Type Name Description
Mat m
| Improve this Doc View Source

CopyTo(SparseMat)

copies all the data to the destination matrix. All the previous content of m is erased.

Declaration
public void CopyTo(SparseMat m)
Parameters
Type Name Description
SparseMat m
| Improve this Doc View Source

Create(MatType, Int32[])

Reallocates sparse matrix. If the matrix already had the proper size and type, it is simply cleared with clear(), otherwise, the old matrix is released (using release()) and the new one is allocated.

Declaration
public void Create(MatType type, params int[] sizes)
Parameters
Type Name Description
OpenCvSharp.MatType type
System.Int32[] sizes
| Improve this Doc View Source

Depth()

Returns the depth of sparse matrix element.

Declaration
public int Depth()
Returns
Type Description
System.Int32
| Improve this Doc View Source

Dims()

Returns the matrix dimensionality

Declaration
public int Dims()
Returns
Type Description
System.Int32
| Improve this Doc View Source

DisposeUnmanaged()

Releases unmanaged resources

Declaration
protected override void DisposeUnmanaged()
Overrides
DisposableCvObject.DisposeUnmanaged()
| Improve this Doc View Source

ElemSize()

returns the size of each element in bytes (not including the overhead - the space occupied by SparseMat::Node elements)

Declaration
public int ElemSize()
Returns
Type Description
System.Int32
| Improve this Doc View Source

ElemSize1()

returns elemSize()/channels()

Declaration
public int ElemSize1()
Returns
Type Description
System.Int32
| Improve this Doc View Source

Find<T>(Int32, Int32, Int32, Nullable<Int64>)

Return pthe specified sparse matrix element if it exists; otherwise, null.

Declaration
public T? Find<T>(int i0, int i1, int i2, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

System.Int32 i2

Index along the dimension 2

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
System.Nullable<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Find<T>(Int32, Int32, Nullable<Int64>)

Return pthe specified sparse matrix element if it exists; otherwise, null.

Declaration
public T? Find<T>(int i0, int i1, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
System.Nullable<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Find<T>(Int32, Nullable<Int64>)

Return pthe specified sparse matrix element if it exists; otherwise, null.

Declaration
public T? Find<T>(int i0, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
System.Nullable<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Find<T>(Int32[], Nullable<Int64>)

Return pthe specified sparse matrix element if it exists; otherwise, null.

Declaration
public T? Find<T>(int[] idx, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32[] idx

Array of Mat::dims indices.

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
System.Nullable<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

FromMat(Mat)

Create SparseMat from Mat

Declaration
public static SparseMat FromMat(Mat mat)
Parameters
Type Name Description
Mat mat
Returns
Type Description
SparseMat
| Improve this Doc View Source

Get<T>(Int32, Int32, Int32, Nullable<Int64>)

Returns a value to the specified array element.

Declaration
public T Get<T>(int i0, int i1, int i2, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

System.Int32 i2

Index along the dimension 2

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
T

A value to the specified array element.

Type Parameters
Name Description
T
| Improve this Doc View Source

Get<T>(Int32, Int32, Nullable<Int64>)

Returns a value to the specified array element.

Declaration
public T Get<T>(int i0, int i1, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
T

A value to the specified array element.

Type Parameters
Name Description
T
| Improve this Doc View Source

Get<T>(Int32, Nullable<Int64>)

Returns a value to the specified array element.

Declaration
public T Get<T>(int i0, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
T

A value to the specified array element.

Type Parameters
Name Description
T
| Improve this Doc View Source

Get<T>(Int32[], Nullable<Int64>)

Returns a value to the specified array element.

Declaration
public T Get<T>(int[] idx, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32[] idx

Array of Mat::dims indices.

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
T

A value to the specified array element.

Type Parameters
Name Description
T
| Improve this Doc View Source

GetIndexer<T>()

Gets a type-specific indexer. The indexer has getters/setters to access each matrix element.

Declaration
public SparseMat.Indexer<T> GetIndexer<T>()
    where T : struct
Returns
Type Description
SparseMat.Indexer<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Hash(Int32)

Computes the element hash value (1D case)

Declaration
public long Hash(int i0)
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

Returns
Type Description
System.Int64
| Improve this Doc View Source

Hash(Int32, Int32)

Computes the element hash value (2D case)

Declaration
public long Hash(int i0, int i1)
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

Returns
Type Description
System.Int64
| Improve this Doc View Source

Hash(Int32, Int32, Int32)

Computes the element hash value (3D case)

Declaration
public long Hash(int i0, int i1, int i2)
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

System.Int32 i2

Index along the dimension 2

Returns
Type Description
System.Int64
| Improve this Doc View Source

Hash(Int32[])

Computes the element hash value (nD case)

Declaration
public long Hash(params int[] idx)
Parameters
Type Name Description
System.Int32[] idx

Array of Mat::dims indices.

Returns
Type Description
System.Int64
| Improve this Doc View Source

NzCount()

returns the number of non-zero elements (=the number of hash table nodes)

Declaration
public long NzCount()
Returns
Type Description
System.Int64
| Improve this Doc View Source

Ptr(Int32, Boolean, Nullable<Int64>)

Low-level element-access function.

Declaration
public IntPtr Ptr(int i0, bool createMissing, long? hashVal = null)
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Boolean createMissing

Create new element with 0 value if it does not exist in SparseMat.

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
IntPtr
| Improve this Doc View Source

Ptr(Int32, Int32, Boolean, Nullable<Int64>)

Low-level element-access function.

Declaration
public IntPtr Ptr(int i0, int i1, bool createMissing, long? hashVal = null)
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

System.Boolean createMissing

Create new element with 0 value if it does not exist in SparseMat.

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
IntPtr
| Improve this Doc View Source

Ptr(Int32, Int32, Int32, Boolean, Nullable<Int64>)

Low-level element-access function.

Declaration
public IntPtr Ptr(int i0, int i1, int i2, bool createMissing, long? hashVal = null)
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

System.Int32 i2

Index along the dimension 2

System.Boolean createMissing

Create new element with 0 value if it does not exist in SparseMat.

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
IntPtr
| Improve this Doc View Source

Ptr(Int32[], Boolean, Nullable<Int64>)

Low-level element-access function.

Declaration
public IntPtr Ptr(int[] idx, bool createMissing, long? hashVal = null)
Parameters
Type Name Description
System.Int32[] idx

Array of Mat::dims indices.

System.Boolean createMissing

Create new element with 0 value if it does not exist in SparseMat.

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
IntPtr
| Improve this Doc View Source

Ref<T>()

Gets a type-specific indexer. The indexer has getters/setters to access each matrix element.

Declaration
public SparseMat.Indexer<T> Ref<T>()
    where T : struct
Returns
Type Description
SparseMat.Indexer<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Release()

Releases the resources

Declaration
public void Release()
| Improve this Doc View Source

Set<T>(Int32, T, Nullable<Int64>)

Set a value to the specified array element.

Declaration
public void Set<T>(int i0, T value, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

T value
System.Nullable<System.Int64> hashVal
Type Parameters
Name Description
T
| Improve this Doc View Source

Set<T>(Int32, Int32, T, Nullable<Int64>)

Set a value to the specified array element.

Declaration
public void Set<T>(int i0, int i1, T value, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

T value
System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Type Parameters
Name Description
T
| Improve this Doc View Source

Set<T>(Int32, Int32, Int32, T, Nullable<Int64>)

Set a value to the specified array element.

Declaration
public void Set<T>(int i0, int i1, int i2, T value, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

System.Int32 i2

Index along the dimension 2

T value
System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Type Parameters
Name Description
T
| Improve this Doc View Source

Set<T>(Int32[], T, Nullable<Int64>)

Set a value to the specified array element.

Declaration
public void Set<T>(int[] idx, T value, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32[] idx

Array of Mat::dims indices.

T value
System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Type Parameters
Name Description
T
| Improve this Doc View Source

Size()

Returns the array of sizes, or null if the matrix is not allocated

Declaration
public int[] Size()
Returns
Type Description
System.Int32[]
| Improve this Doc View Source

Size(Int32)

Returns the size of i-th matrix dimension (or 0)

Declaration
public int Size(int dim)
Parameters
Type Name Description
System.Int32 dim
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToString()

Returns a string that represents this Mat.

Declaration
public override string ToString()
Returns
Type Description
System.String
| Improve this Doc View Source

Type()

Returns the type of sparse matrix element.

Declaration
public MatType Type()
Returns
Type Description
OpenCvSharp.MatType
| Improve this Doc View Source

Value<T>(Int32, Int32, Int32, Nullable<Int64>)

Return pthe specified sparse matrix element if it exists; otherwise, default(T).

Declaration
public T Value<T>(int i0, int i1, int i2, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

System.Int32 i2

Index along the dimension 2

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
T
Type Parameters
Name Description
T
| Improve this Doc View Source

Value<T>(Int32, Int32, Nullable<Int64>)

Return pthe specified sparse matrix element if it exists; otherwise, default(T).

Declaration
public T Value<T>(int i0, int i1, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Int32 i1

Index along the dimension 1

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
T
Type Parameters
Name Description
T
| Improve this Doc View Source

Value<T>(Int32, Nullable<Int64>)

Return pthe specified sparse matrix element if it exists; otherwise, default(T).

Declaration
public T Value<T>(int i0, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32 i0

Index along the dimension 0

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
T
Type Parameters
Name Description
T
| Improve this Doc View Source

Value<T>(Int32[], Nullable<Int64>)

Return pthe specified sparse matrix element if it exists; otherwise, default(T).

Declaration
public T Value<T>(int[] idx, long? hashVal = null)
    where T : struct
Parameters
Type Name Description
System.Int32[] idx

Array of Mat::dims indices.

System.Nullable<System.Int64> hashVal

If hashVal is not null, the element hash value is not computed but hashval is taken instead.

Returns
Type Description
T
Type Parameters
Name Description
T

Implements

ICvPtrHolder
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX