Package qupath.opencv.dnn
Class DnnShape
java.lang.Object
qupath.opencv.dnn.DnnShape
Helper class to represent input and output shapes associated with
PredictionFunction.
In general, the shape is expected to be in the format NCHW.
NCHW is used by OpenCV https://docs.opencv.org/4.5.2/d6/d0f/group__dnn.html#ga29f34df9376379a603acd8df581ac8d7 and also by PyTorch; for TensorFlow some rearrangement may be needed.
Note: NDCHW support may be added in the future, but is not currently supported.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic longConstant to represent an unknown dimension length.static DnnShapeConstant to represent an unknown shape.static longConstant to represent an unknown size (i.e. -
Method Summary
Modifier and TypeMethodDescriptionfinal longget(int i) Get the length of the specified dimension.final long[]getShape()Get a copy of the internal dimensions array.final booleanReturns true if the shape is unknown.final intThe total number of dimensions, i.e.static DnnShapeof(long... shape) Create a newDnnShapewith the specified dimension lengths.final longsize()Total number of elements in a blob with this shape This is the product of the lengths returned bygetShape()orUNKNOWN_SHAPE.toString()
-
Field Details
-
UNKNOWN_SHAPE
Constant to represent an unknown shape. -
UNKNOWN_LENGTH
public static long UNKNOWN_LENGTHConstant to represent an unknown dimension length. -
UNKNOWN_SIZE
public static long UNKNOWN_SIZEConstant to represent an unknown size (i.e. number of elements within a blob, mat or tensor).
-
-
Method Details
-
getShape
public final long[] getShape()Get a copy of the internal dimensions array.- Returns:
-
get
public final long get(int i) Get the length of the specified dimension.- Parameters:
i-- Returns:
-
of
Create a newDnnShapewith the specified dimension lengths.- Parameters:
shape-- Returns:
-
numDimensions
public final int numDimensions()The total number of dimensions, i.e. the length of the array returned bygetShape().- Returns:
-
isUnknown
public final boolean isUnknown()Returns true if the shape is unknown.- Returns:
-
size
public final long size()Total number of elements in a blob with this shape This is the product of the lengths returned bygetShape()orUNKNOWN_SHAPE.- Returns:
-
toString
-