vision-camera-resize-plugin
vision-camera-resize-plugin copied to clipboard
Float32 array returns zeroed out values past index 128 on each row
Hi, I'm trying to pipe vision camera output into a tflite face detection model that requires 128x128x3 float32 input. Here's the relevant code:
const IMAGE_SIZE = 128
const COLOR_CHANNELS = 3
const data = resize(frame, {
crop: {
x: 0,
y: 0,
width: frame.width,
height: frame.height,
},
scale: {
width: IMAGE_SIZE,
height: IMAGE_SIZE,
},
pixelFormat: 'rgb',
dataType: 'float32',
})
// log out first row of image (and 1st pixel R value of the second row)
console.log('first row plus 1px', data.slice(0, IMAGE_SIZE * COLOR_CHANNELS + 1))
const outputs = bfsr.model?.runSync([data])
I was noticing that my face would only be detected if it was in the left side of the screen. Upon inspecting the resized array, I noticed that only the first 128 indices from each row had values:
This did not happen when I changed dataType
to uint8
:
Am I missing something? Thanks!