OpenCV 获取矩阵的形状

OpenCV Get the Shape of the Matrix

我正在使用这个库来探索 OpenCV:https://github.com/bytedeco/javacv

我正在尝试了解如何获得 Matrix 的形状。在 Python 中,这类似于:

import cv2
image = cv2.imread("example.png")
print(image.shape)

我在 Mat class 中没有看到可以给我加载矩阵形状的等效函数。这是 Java 等价物:

val matrix: Mat = imread("data/Pixel_Artistry.jpeg")

似乎没有内置功能,但可以这样完成:

println(s"[${matrix.rows} ${matrix.cols()} ${matrix.channels()}]")