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!
Huh - interesting. iOS or Android?
Observed on iOS
I just noticed the same thing (also on iOS). To verify / understand the content of my frames, I created a simple demo app that stores the frame content returned from the resize plugin and just draws it right below the original image via react-native-skia.
With uint8
it looks just fine:
But with float32
, only the left side is painted:
Hey - can you send me a link to a public github repo where I can also see this appear on the left side? That'd help me debug.
I'm not sure if you mean me, but here I have created a demo repository which visualizes the image stream via skia (not really stable, but is suitable for debugging).
yep perfect, thanks! I'll take a look next week or so :)
Hey - is this still an issue? cc @rodgomesc