recognizeImage method
从图片文件路径识别文字。
Implementation
@override
Future<List<OcrResult>> recognizeImage(String imagePath) async {
_log('recognizeImage: imagePath="$imagePath"');
_log('recognizeImage: path codeUnits=${imagePath.codeUnits}');
try {
final result = await _channel.invokeMethod<List<dynamic>>('recognizeImage', {
'imagePath': imagePath,
});
_log('recognizeImage: native returned ${result?.length ?? 0} items');
if (result == null) return [];
return _parseResults(result);
} on FormatException catch (e) {
_log('recognizeImage: FormatException! offset=${e.offset} message=${e.message}');
_log('recognizeImage: This usually means native code returned invalid UTF-8 bytes.');
_log('recognizeImage: Check the native stderr log for hex dumps of the data.');
rethrow;
} on PlatformException catch (e) {
_log('recognizeImage: PlatformException code=${e.code} message=${e.message} '
'details=${e.details}');
rethrow;
} catch (e, st) {
_log('recognizeImage: unexpected error', error: e, stackTrace: st);
rethrow;
}
}