scala - OpenCV 获取矩阵的形状
问题描述
我正在使用这个库来探索 OpenCV:https ://github.com/bytedeco/javacv
我试图了解如何获得矩阵的形状。在 Python 中,这将类似于:
import cv2
image = cv2.imread("example.png")
print(image.shape)
我没有在 Mat 类中看到可以为我提供加载矩阵的形状的等效函数。这是Java等价物:
val matrix: Mat = imread("data/Pixel_Artistry.jpeg")
解决方案
似乎没有内置功能,但这可以像这样完成:
println(s"[${matrix.rows} ${matrix.cols()} ${matrix.channels()}]")
推荐阅读
- css - 如何将 PostCSS 转换为有效的 CSS 代码?
- android - Android 视图背景使适合中心
- class-diagram - PlantUML类图中两个同名的类
- keycloak - Keycloak中用户的多种身份验证方法
- javascript - 以外部剪贴蒙版的形状裁剪图像-fabric.js
- mysql - 使用插入/更新加快 SQL 处理时间
- sql-server - SQL 服务器计划缓存
- mongodb - 在 Golang 的两个不同结构字段中映射 Mongo _id
- mips - Little Endian Mips 操作
- swift - 使用 Alamofire 上传多部分表单数据显示服务器中缺少文件