Struct MatShape
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
Represents the shape of a matrix / tensor (OpenCV 5, cv::MatShape). In addition to the per-axis sizes it carries the data Layout and, for the block layout, the actual number of Channels (C). It also distinguishes an empty shape (IsEmpty, total == 0) from a 0-dimensional scalar shape (IsScalar, dims == 0 but total == 1).
public readonly struct MatShape : IEquatable<MatShape>
- Implements
- Inherited Members
Constructors
- MatShape(IEnumerable<int>, DataLayout, int)
Creates an N-D shape with an explicit layout and channel count.
- MatShape(params int[])
Creates an N-D shape from the given per-axis sizes. Passing no sizes creates a 0-D scalar shape.
Properties
- Channels
Actual number of channels (C), meaningful for the block layout; 0 otherwise.
- Dims
The number of dimensions (axes). 0 for both empty and scalar shapes.
- Empty
An empty shape (total == 0).
- IsEmpty
True if this is an empty shape (total == 0).
- IsScalar
True if this is a 0-dimensional scalar shape (dims == 0, total == 1).
- this[int]
Gets the size of the i-th axis.
- Layout
Data layout of the shape.
- Total
The total number of elements: 0 for an empty shape, 1 for a scalar, otherwise the product of the sizes.
Methods
- Equals(MatShape)
Indicates whether the current object is equal to another object of the same type.
- Equals(object?)
Indicates whether this instance and a specified object are equal.
- GetHashCode()
Returns the hash code for this instance.
- Scalar(DataLayout)
A 0-dimensional scalar shape (dims == 0, total == 1).
- ToArray()
Returns the per-axis sizes as an array (empty array for empty or scalar shapes).
- ToString()
Returns the fully qualified type name of this instance.
Operators
- operator ==(MatShape, MatShape)
Determines whether two shapes are equal (same sizes, layout and channels).
- explicit operator int[](MatShape)
Returns the per-axis sizes.
- implicit operator MatShape(int[]?)
Implicitly converts per-axis sizes to a MatShape. A null array becomes an empty shape.
- operator !=(MatShape, MatShape)
Determines whether two shapes differ.