【发布时间】:2021-10-12 17:29:25
【问题描述】:
我有一个图像处理服务器,我正在尝试解决以下问题:
logger info "calling detect"
// read from file, pretty fast
val bytes = new FileInputStream(frame getPath) readAllBytes()
// I can tell because this line executes immediately
logger info (s"the image was read as ${bytes length}")
// also trivial
val imageMat = new Mat(frame.width, frame.height, 1)
logger info "constructed empty matrix..."
// this takes a long time, as I cannot see the log line that follows
imageMat put (0, 0, bytes)
logger info s"read image as matrix: ${imageMat dump()}"
这个 sn-p 从字节数组中加载图像 (.bgr888),创建一个具有图像宽度/长度的空矩阵(我从 gRPC 请求中获得),然后用值填充矩阵的字节数组。只有最后一步需要永远。
我尝试将字节数组包装为 ByteBuffer 并直接传递给矩阵构造函数,但这违反了一些关于数据为 0 或 null 的 C++ 断言,这对我来说很奇怪,因为显然数据两者都不是,但我不是C++ 开发人员不知道这是怎么回事。
【问题讨论】:
-
您可以添加您尝试使用 ByteBuffer 的代码吗?
标签: java scala opencv image-processing optimization