recognize method
Future<List<OcrResult> >
recognize(
- Object handle,
- Uint8List imageBytes, {
- int maxSideLen = 960,
- bool runDetection = true,
- bool runClassification = false,
- 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 ocr = handle as _JsOcr;
final blob = web.Blob(
[imageBytes.toJS].toJS,
web.BlobPropertyBag(type: 'image/jpeg'),
);
final jsResult = await ocr.predict(blob).toDart;
final list = jsResult.toDart;
if (list.isEmpty) return const [];
final first = list.first;
final items = first.items;
if (items == null) return const [];
return items.toDart.map(_fromJs).toList(growable: false);
}