recognizeImageBytes method
从图片字节数据识别文字。
Implementation
@override
Future<List<OcrResult>> recognizeImageBytes(Uint8List imageBytes) async {
_log('recognizeImageBytes: ${imageBytes.length} bytes');
try {
final result =
await _channel.invokeMethod<List<dynamic>>('recognizeImageBytes', {
'imageBytes': imageBytes,
});
_log('recognizeImageBytes: native returned ${result?.length ?? 0} items');
if (result == null) return [];
return _parseResults(result);
} on FormatException catch (e) {
_log('recognizeImageBytes: FormatException! offset=${e.offset} message=${e.message}');
_log('recognizeImageBytes: This usually means native code returned invalid UTF-8 bytes.');
rethrow;
} on PlatformException catch (e) {
_log('recognizeImageBytes: PlatformException code=${e.code} message=${e.message}');
rethrow;
} catch (e, st) {
_log('recognizeImageBytes: unexpected error', error: e, stackTrace: st);
rethrow;
}
}