The recognizers aim at performing real-time incremental recognition on transient ink.

Setup

In order to use the recognizers, you need to:

Configuration

Text Recognizer

Gesture Recognizer

Supported gestures are defined thanks to recognizer.gesture. prefixed keys.

Shape Recognizer

Math Recognizer

To use the Math Recognizer, you must deploy the corresponding Math resources in your application. They are contained in the myscript-iink-recognition-math2.zip package.

Currently, the Math Recognizer may not be available on your platform. Check if it is available for your platform.

Raw Content Recognizer

To use the Raw Content Recognizer, you must:

In addition to the myscript-iink-recognition-raw-content2.zip package, the following table lists resources that you must deploy in your project according to the recognition types that you use:

Recognition content type Required configuration bundles Resource and configuration package names
text ${recognizer.lang} Language package defined by your recognizer.lang configuration. See principles of language resources
math math2 myscript-iink-recognition-math2.zip
shape shape myscript-iink-recognition-shape.zip
Currently, the Raw Content Recognizer may not be available on your platform. Check if it is available for your platform.

➤ For more details, refer to the configuration and jiix pages.

Common parameters

➤ Refer to the configuration page, to get the full list of recognizer configuration.

Example

The example below illustrates the use of a Raw Content Recognizer for multi-Latin language text, math and shape recognition.

val engine = IInkApplication.getEngine()

engine.apply {
  configuration.apply {
    // Configure recognition search path for recognizer
    val confDir = "zip://${application.packageCodePath}!/assets/conf"
    setStringArray("recognizer.configuration-manager.search-path", arrayOf(confDir))
    // Enable multi Latin language recognition
    setString("recognizer.lang","mul_Latn")
    // Activate classification for text, math, shape and drawing
    setStringArray("recognizer.raw-content.classification.types", arrayOf("text", "math", "shape", "drawing"))
    // Activate handwriting recognition for text, math and shape
    setStringArray("recognizer.raw-content.recognition.types", arrayOf("text", "math", "shape"))
    }
  }

// Create a Raw Content Recognizer
recognizer = engine.createRecognizer(1.0f, 1.0f, "Raw Content")
// Send it your stroke pointer events
recognizer.pointerEvents(pointerEvents)
// Wait for recognition end
recognizer.waitForIdle()
// Get the recognition result
val recognitionResult = recognizer.getResult(MimeType.JIIX)

Recognizer-level versus Engine-level configuration

Engine-level configuration corresponds to the default, global configuration. You can override configuration values at the Recognizer level, which is useful if you manage several Recognizers with different configurations. After setting the recognizer-specific configuration, call the applyConfiguration method to apply it to your recognizer:

recognizer.apply {
  configuration.apply {
    // Prepare the new configuration
    setString("recognizer.lang","fr_FR")
  }
}

// Apply the changed configuration
recognizer.applyConfiguration()

If you have already sent events to your Recognizer, the input will be retained and reprocessing will automatically restart with the new configuration. If you want to remove the input, call the clear before calling the applyConfiguration method.

Advanced example

The write to type example gives you a hint how to implement scribble like feature relying on the Recognizer API of iink SDK. It is available on the MyScript Git repository containing the additional examples for the Android platform. This sample comes with a description that helps you understand its principle.

It is based on a contextless gesture recognition combined with a text recognition. To run both recognitions simultaneously, two instances of Recognizer are created - one for Gesture recognition and the other one for Text recognition.

➤ Should you need more details, refer to the API documentation documentation and/or ask question on our developer forum.