buildIOSInputImage static method

InputImage? buildIOSInputImage(
  1. CameraImage image,
  2. InputImageRotation rotation
)

Implementation

static InputImage? buildIOSInputImage(CameraImage image, InputImageRotation rotation) {
  final format = InputImageFormatValue.fromRawValue(image.format.raw);

  if (format != InputImageFormat.bgra8888 || image.planes.length != 1) {
    log('iOS format issue: format=$format, planes=${image.planes.length}');
    return null;
  }

  final plane = image.planes.first;

  return InputImage.fromBytes(
    bytes: plane.bytes,
    metadata: InputImageMetadata(
      size: Size(image.width.toDouble(), image.height.toDouble()),
      rotation: rotation,
      format: format!,
      bytesPerRow: plane.bytesPerRow,
    ),
  );
}