inputImageFromBytes method
InputImage?
inputImageFromBytes()
Implementation
@visibleForTesting
InputImage? inputImageFromBytes(
Uint8List bytes,
int width,
int height,
int bytesPerRow,
) {
if (_cameraController == null || _availableCameras.isEmpty) return null;
final camera = _availableCameras[_selectedCameraIndex];
final sensorOrientation = camera.sensorOrientation;
final rotation = InputImageRotationValue.fromRawValue(sensorOrientation);
if (rotation == null) return null;
final format = defaultTargetPlatform == TargetPlatform.android
? InputImageFormat.nv21
: InputImageFormat.bgra8888;
return InputImage.fromBytes(
bytes: bytes,
metadata: InputImageMetadata(
size: Size(width.toDouble(), height.toDouble()),
rotation: rotation,
format: format,
bytesPerRow: bytesPerRow,
),
);
}