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
Modifier and TypeFieldDescriptionstatic long
Constant to represent an unknown dimension length.static DnnShape
Constant to represent an unknown shape.static long
Constant to represent an unknown size (i.e. -
Method Summary
Modifier and TypeMethodDescriptionfinal long
get
(int i) Get the length of the specified dimension.final long[]
getShape()
Get a copy of the internal dimensions array.final boolean
Returns true if the shape is unknown.final int
The total number of dimensions, i.e.static DnnShape
of
(long... shape) Create a newDnnShape
with the specified dimension lengths.final long
size()
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 newDnnShape
with 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
-