toInputImage method

InputImage toInputImage({
  1. int rotation = 0,
})

Implementation

InputImage toInputImage({int rotation = 0}) {
  final bytes = Platform.isAndroid ? getNv21Uint8List() : _concatenatePlanes();

  final Size imageSize = Size(width.toDouble(), height.toDouble());

  final InputImageRotation imageRotation = InputImageRotationValue.fromRawValue(rotation)!;

  final InputImageFormat inputImageFormat = InputImageFormatValue.fromRawValue(format.raw)!;

  final metadata = InputImageMetadata(
    size: imageSize,
    rotation: imageRotation,
    format: Platform.isAndroid ? InputImageFormat.nv21 : inputImageFormat,
    bytesPerRow: planes.first.bytesPerRow,
  );

  return InputImage.fromBytes(bytes: bytes, metadata: metadata);
}