recognize method

  1. @override
Future<List<OcrResult>> recognize(
  1. Object handle,
  2. Uint8List imageBytes, {
  3. int maxSideLen = 960,
  4. bool runDetection = true,
  5. bool runClassification = false,
  6. bool runRecognition = true,
})
override

Runs OCR on an image encoded in a browser/native-decodable format.

Implementation

@override
Future<List<OcrResult>> recognize(
  Object handle,
  Uint8List imageBytes, {
  int maxSideLen = 960,
  bool runDetection = true,
  bool runClassification = false,
  bool runRecognition = true,
}) async {
  final raw = await methodChannel.invokeListMethod<dynamic>(_Channel.recognize, {
    _Channel.instanceId: handle as int,
    _Channel.imageBytes: imageBytes,
    _Channel.maxSideLen: maxSideLen,
    _Channel.runDetection: runDetection,
    _Channel.runClassification: runClassification,
    _Channel.runRecognition: runRecognition,
  });
  return (raw ?? const [])
      .cast<Map<dynamic, dynamic>>()
      .map(OcrResult.fromMap)
      .toList(growable: false);
}