I used cv.blobFromImage
to convert opencv Mat
object directly to blob, no canvas needed.
const blob = cv.blobFromImage(
image, // cv.Mat
1 / 128, // scalefactor
new cv.Size(inputWeight, inputHeight), // size
new cv.Scalar(inputMean, inputMean, inputMean), // mean
true // swapRB
);
See OpenCV: Deep Neural Network module for API docs.