bgrBytesToSignedFloat32 function
Float32List
bgrBytesToSignedFloat32({
- required Uint8List bytes,
- required int totalPixels,
- Float32List? buffer,
Converts BGR bytes to a flat Float32List with -1.0, 1.0 normalization.
Performs a BGR→RGB channel swap and normalizes via (value / 127.5) - 1.0, as used by models expecting signed normalized input.
Parameters:
bytes: Raw BGR image bytes (length must be totalPixels * 3)totalPixels: Total number of pixels (width * height)buffer: Optional pre-allocated Float32List of length totalPixels * 3 to reuse
Returns a flat Float32List with normalized RGB pixel values in -1.0, 1.0.
Implementation
Float32List bgrBytesToSignedFloat32({
required Uint8List bytes,
required int totalPixels,
Float32List? buffer,
}) => _bgrToRgbFloat32(
bytes: bytes,
totalPixels: totalPixels,
scale: 1.0 / 127.5,
offset: -1.0,
buffer: buffer,
);