mrousavy / vision-camera-resize-plugin

A VisionCamera Frame Processor plugin for fast buffer resizing and colorspace (YUV <> RGBA) conversions
https://mrousavy.com
MIT License
93 stars 23 forks source link

fix: Float32 conversion on IOS #54

Closed wojtke closed 6 months ago

wojtke commented 7 months ago

Fixing this: https://github.com/mrousavy/vision-camera-resize-plugin/issues/40

Upon some digging, we found out that when using RGB (or other 3 channel formats) 1/3 of the camera is zeroed out and when using RGBA (4 channels) 1/4 of the camera is zeroed out.

This was caused by incorrect usage of vImageConvert_Planar8toPlanarF, when in reality the buffers were interleaved, not planar.

Having assumed different memory layout, the converter function acted as if the image rows were N_CHANNELS times shorter in terms of bytes than in reality, resulting in that strange behavior.

If we convert manually, this doesnt happen. I used vDSP_vfltu8, vDSP_vsmul so things go fast.

mrousavy commented 6 months ago

now :)