google_mlkit_digital_ink_recognition 0.2.1
google_mlkit_digital_ink_recognition: ^0.2.1 copied to clipboard
A Flutter plugin to use Google's ML Kit Digital Ink Recognition to recognize handwritten text on a digital surface in hundreds of languages, as well as classify sketches.
Google's ML Kit Digital Ink Recognition for Flutter #
A Flutter plugin to use Google's ML Kit Digital Ink Recognition to recognize handwritten text on a digital surface in hundreds of languages, as well as classify sketches.
Getting Started #
Before you get started read about the requirements and known issues of this plugin here.
Usage #
Digital Ink Recognition #
Create an instance of DigitalInkRecognizer
String languageCode; // BCP-47 Code from https://developers.google.com/ml-kit/vision/digital-ink-recognition/base-models?hl=en#text
final digitalInkRecognizer = DigitalInkRecognizer(languageCode: languageCode);
Process ink
Stroke stroke1 = Stroke(); // it contains all of the StrokePoint
stroke1.point = [StrokePoint(x: x1, y: y1, t: t1), StrokePoint(x: x2, y: y2, t: t2), ...]
Ink ink = Ink(); // it contains all of the Stroke
ink.strokes = [stroke1, stroke2, ...];
final List<RecognitionCandidate> candidates = await digitalInkRecognizer.recognize(ink);
for (final candidate in candidates) {
final text = candidate.text;
final score = candidate.score;
}
Make sure you download the language model before processing any Ink
.
Release resources with close()
digitalInkRecognizer.close();
Managing remote models #
Create an instance of model manager
final modelManager = DigitalInkRecognizerModelManager();
Check if model is downloaded
final bool response = await modelManager.isModelDownloaded(model);
Download model
final bool response = await modelManager.downloadModel(model);
Delete model
final bool response = await modelManager.deleteModel(model);
Example app #
Find the example app here.
Contributing #
Contributions are welcome. In case of any problems look at existing issues, if you cannot find anything related to your problem then open an issue. Create an issue before opening a pull request for non trivial fixes. In case of trivial fixes open a pull request directly.