MatShape
import { MatShape } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Native object: release it with using or delete(). Factories can return null; check before calling methods.
An owned OpenCV 5 tensor shape with up to ten dimensions and layout metadata. Construct from an IntVector, or use scalar() for a zero-dimensional tensor. Dispose the shape after use.
Constructors and members
static new
Create an owned MatShape object. Release native handles with using or delete().
new(shape: IntVector): MatShape;shapeshape argument (IntVector).
The MatShape result.
static scalar
Create an owned zero-dimensional shape containing one element.
scalar(): MatShape;The MatShape result.
clone
Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.
clone(): this;The this result.
dims
Number of tensor dimensions. Zero denotes a scalar; a negative value denotes an empty shape.
readonly dims: number;layout
Numeric DATA_LAYOUT constant describing the dimension order.
readonly layout: number;C
Actual channel count when the shape uses a padded block layout.
readonly C: number;size
Return the number of dimension extents. Use empty() to distinguish an empty shape from a scalar.
size(): number;The number result.
total
Return the product of dimension extents including block padding. Scalars contain one element; empty shapes contain zero.
total(): number;The number result.
vec
Copy the dimension extents into an owned IntVector. Dispose the returned vector.
vec(): IntVector;The IntVector result. Release returned native handles with using or delete(), including handles nested in results.
str
Format the native shape and layout as a diagnostic string.
str(): string;The string result.
empty
Return whether this shape has zero elements.
empty(): boolean;The boolean result.
isScalar
Return whether the shape has zero dimensions and represents a scalar.
isScalar(): boolean;The boolean result.
clear
Reset this shape to the empty state.
clear(): void;channels
Return the channel extent according to the stored data layout.
channels(): number;The number result.
hasSymbols
Return whether any negative extent represents a symbolic dimension.
hasSymbols(): boolean;The boolean result.
expand
Compute the broadcast result of this shape and another shape. Return an owned shape, or throw when dimensions are incompatible.
expand(another: MatShape): MatShape;anotheranother argument (MatShape).
The MatShape result.
erase
Remove the dimension at the supplied zero-based index. Throws when the index is outside the current dimensions.
erase(index: number): void;indexindex argument (number).
toLayout
Convert dimension ordering to the requested numeric DATA_LAYOUT constant. The optional second argument supplies the block channel size. Return an owned shape.
toLayout(newLayout: number, C0: number): MatShape;2 available overloads
toLayout(newLayout: number): MatShape;toLayout(newLayout: number, C0: number): MatShape;newLayoutnew layout argument (number).
C0c0 argument (number).
The MatShape result.
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.