Digital Ink Recognizer

The ML Kit Digital Ink Recognition API offers the capability to identify handwritten text, classify gestures on a digital surface, and recognize sketches. This technology, which is employed in Gboard, Google Translate, and the Quick, Draw! game, supports hundreds of languages.

Key features of digital ink recognition include:

  • Allowing users to write on the screen instead of using a virtual keyboard, enabling the input of characters not readily available on their keyboard (e.g., ệ, अ, or 森 for Latin alphabet keyboards).

  • Recognizing hand-drawn shapes and emojis (via Auto Draw Model).

This API operates based on the strokes drawn by the user on the screen. Digital ink recognition functions entirely offline and is compatible with both Android and iOS platforms.

Import VoxelBusters.EasyMLKit and VoxelBusters.CoreLibrary namespaces

using VoxelBusters.EasyMLKit;
using VoxelBusters.CoreLibrary;

Create Instance

Create an instance of the DigitalInkRecognizer instance by passing one of the input sources.

private DigitalInkRecognizer CreateDigitalInkRecognizer()
{
    DigitalInkRecognizer recognizer = new DigitalInkRecognizer();   
    return recognizer;
}

Check for Model Availability

For using Digital Ink feature, you need to first check if the model that is internally used is available or not. If it's not available, it needs to be downloaded. The model handling is handled by an utility class called DigitalInkRecognizerModelManager

// Get Model Manager from DigitalInkRecognizer instance
// recognizerInstance = new DigitalInkRecognizer(); 
// ...
private DigitalInkRecognizerModelManager GetModelManager()
{
    DigitalInkRecognizerModelManager modelManager = recognizerInstance.GetModelManager();
    return modelManager;
}

Each model is referred with an identifier. So first create the model identifier

Check if a model identifier exists with model manager

If a model identifier is not available, just download it with model manager

Prepare

Once a required model is available, you can call Prepare. For preparing, you need to pass on an Drawing Input Source on which you add the strokes and DigitalInkRecognizerOptions. A callback is triggered when prepare is complete.

Process

Once prepare is complete, you can start processing which gives the result in a callback.

Close

Close the scanner once you are done processing.

Last updated