toInputImage method

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

Implementation

InputImage toInputImage({int rotation = 0}) {
  final WriteBuffer allBytes = WriteBuffer();

  for (final Plane plane in this.planes) {
    allBytes.putUint8List(plane.bytes);
  }

  final bytes = Platform.isAndroid ? this.getNv21Uint8List() : allBytes.done().buffer.asUint8List();

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

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

  final InputImageFormat inputImageFormat = InputImageFormatValue.fromRawValue(this.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);
}