I have an image processing server and I am trying to work through the following:
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()}"
This snippet loads an image (.bgr888) from as an array of bytes, creates an empty matrix with the width/length of the image (which I have from a gRPC request), then populates the matrix with the values of the byte array. Only that last step takes forever.
I tried wrapping the byte array as a ByteBuffer and passing directly to the matrix constructor but that violated some C++ assertion about the data being 0 or null, which is weird to me since clearly the data is neither, but I am not a C++ dev so idk what's going on with that.