Class SparseMat
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
Sparse matrix (cv::SparseMat). This type-erased base exposes the structural and metadata operations that do not depend on the element type. For typed element access use SparseMat<T> (e.g. via As<T>()).
public class SparseMat : CvObject, IDisposable
- Inheritance
-
SparseMat
- Implements
- Derived
-
SparseMat<T>
- Inherited Members
Constructors
SparseMat()
Creates an empty SparseMat.
public SparseMat()
SparseMat(Mat)
Converts a dense cv::Mat to a sparse matrix.
public SparseMat(Mat m)
Parameters
mMatcv::Mat object
SparseMat(IEnumerable<int>, MatType)
Constructs an n-dimensional sparse matrix.
public SparseMat(IEnumerable<int> sizes, MatType type)
Parameters
sizesIEnumerable<int>Array of integers specifying an n-dimensional array shape.
typeMatTypeArray type.
SparseMat(nint)
Creates from a native cv::SparseMat* pointer.
public SparseMat(nint ptr)
Parameters
ptrnint
Methods
AddRef()
Manually increments the reference counter to the header.
public void AddRef()
As<T>()
Returns a typed view of this sparse matrix. The element type must match this matrix's type. The returned matrix shares the data with this one (O(1)).
public SparseMat<T> As<T>() where T : unmanaged
Returns
- SparseMat<T>
Type Parameters
TElement type matching this matrix's Type().
AssignFrom(Mat)
Assignment from a dense matrix (equivalent to the corresponding constructor).
public SparseMat AssignFrom(Mat m)
Parameters
mMat
Returns
AssignFrom(SparseMat)
Assignment operator. This is an O(1) operation that shares the data.
public SparseMat AssignFrom(SparseMat m)
Parameters
Returns
AssignTo(SparseMat, MatType?)
public void AssignTo(SparseMat m, MatType? type = null)
Parameters
Channels()
Returns the number of sparse matrix channels.
public int Channels()
Returns
Clear()
Sets all the matrix elements to 0, which means clearing the hash table.
public void Clear()
Clone()
Creates a full copy of the matrix.
public SparseMat Clone()
Returns
ConvertTo(Mat, MatType, double, double)
Converts sparse matrix to dense matrix.
public void ConvertTo(Mat m, MatType rtype, double alpha = 1, double beta = 0)
Parameters
ConvertTo(SparseMat, MatType, double)
Multiplies all the matrix elements by the specified scale factor.
public void ConvertTo(SparseMat m, MatType rtype, double alpha = 1)
Parameters
CopyTo(Mat)
Converts the sparse matrix to a dense matrix.
public void CopyTo(Mat m)
Parameters
mMat
CopyTo(SparseMat)
Copies all the data to another sparse matrix.
public void CopyTo(SparseMat m)
Parameters
Create(MatType, params int[])
Reallocates the sparse matrix.
public void Create(MatType type, params int[] sizes)
Parameters
Depth()
Returns the depth of sparse matrix element.
public int Depth()
Returns
Dims()
Returns the matrix dimensionality.
public int Dims()
Returns
ElemSize()
Returns the size of each element in bytes.
public int ElemSize()
Returns
ElemSize1()
Returns the size of each element channel in bytes.
public int ElemSize1()
Returns
FromMat(Mat)
Creates a sparse matrix from a dense cv::Mat.
public static SparseMat FromMat(Mat mat)
Parameters
matMat
Returns
NzCount()
Returns the number of non-zero elements (the number of hash table nodes).
public long NzCount()
Returns
Release()
Releases the resources.
public void Release()
Size()
Returns the array of sizes, or null if the matrix is not allocated.
public int[] Size()
Returns
- int[]
Size(int)
Returns the size of i-th matrix dimension (or 0).
public int Size(int dim)
Parameters
dimint
Returns
ToMat()
Converts this sparse matrix to a new dense Mat of the same type.
public Mat ToMat()
Returns
ToString()
Returns a string that represents this SparseMat.
public override string ToString()
Returns
Type()
Returns the type of sparse matrix element.
public MatType Type()