Call to <host_of_rest_endpoint>/api/v4.0/iink/recognize/
allows you to use our recognizer engine to recognize digital content from your already collected strokes.
Depending on its Content Type configuration, the iink REST recognizer API performs a specific following types of recognition.
The body of the request contains several parts to adjust the recognition (in bold are the mandatory parts):
Overview of the request body:
{
"scaleX": 0.625,
"scaleY": 0.625,
"contentType": "Text",
"configuration": {
"lang": "en_US",
...
},
"strokes": []
}
You will find complete request bodies in the Swagger-ui or in the examples listed below.
Although you might not display the strokes, you need to provide proper scale values. These correspond to the scale of your input surface, be it a digital screen or a sheet of paper, to convert input coordinates unit into mm, such that (X coordinate unit * scaleX = mm) and (Y coordinate unit * scaleY = mm).
The scaleX
and scaleY
values must be strictly positive.
An input stroke is represented by arrays:
x
array contains the x coordinates of the points of the strokey
array contains the y coordinates of the points of the stroket
array contains the timestamps in milliseconds of the points of the stroke. There is no need for them to represent the exact epoch time of the point as the recognition engine will treat each of them in comparison with the first one.p
array describe the normalized pressure for each stroke point. Pressure values must respect 0 < value < 1
.You can assign an optional id
attribute to the stroke.
You can provide an optional pointerId
attribute. The pointer id identifies the device that was used to write the stroke (the id of the stylus or pencil, the finger that is moving in case of two-finger touch, …).
Ink strokes are grouped in strokes
.
Here is an example of the iink input for a series of three strokes.
"strokes": [
{
"x":[167,164,162,160,158,157,156,155,154,153],
"y":[124,129,133,137,143,146,149,152,155,159],
"t":[0,141,159,175,191,208,225,241,275,308]
},
{
"x":[212,210,209,208,208,207,204,203,202,201,201,201,201],
"y":[123,131,135,139,142,145,150,153,157,160,163,166,169],
"t":[1238,1292,1309,1326,1342,1360,1393,1409,1427,1443,1460,1476,1493]
},
{
"x":[148,151,155,158,163,168,171,176,180,184,187,190],
"y":[170,169,168,167,167,167,167,167,168,170,171,174],
"t":[4897,5043,5078,5094,5128,5159,5177,5210,5227,5260,5293,5328],
}
]
The language for the text recognition in Text and Raw Content is configured in the configuration.lang
attribute.
The language code is build that way:
For example, use en_US
for American English.
Supported languages list for iink SDK 4.0 is available here.
The recognition type is configured using the contentType
attribute. It can have the value: Text
, Math
, Raw Content
, Shape
or Gesture
.
The text recognizer of the iink SDK enables recognition of multiline cursive text in the selected language.
If you ask for application/vnd.myscript.jiix
output, you can have information about how the text was recognized and what were the alternative recognition candidates.
You can also ask for raw text output by using the text/plain
mime type.
Here is an example of Text recognition.
The math recognizer of the iink SDK enables recognition of math equations.
The recognition output is available in LaTeX format with the application/x-latex
mime type.
Default Math resources are generally sufficient for most needs. However, in some cases, it may be necessary to use only a subset of Math symbols or rules: The Subset Knowledge resource (or SK) is a white or black list that works as a filter to constrain the recognition to a specific set of symbols and rules for Math Recognizer.
You can configure your custom SK by using the math.custom-sk
configuration: the content of the SK is set in the content
string, and the type
allows you to choose with either “Math Enabled Subset” option to whitelist it, or “Math Disabled Subset” to blacklist it.
See below example:
"configuration": {
"math": {
"custom-sk": {
"type": "Math Enabled Subset",
"content": "0123456789"
}
}
}
You can get the exhaustive list of math and and rules symbols that is supported by the SK here.
Here are some examples of Math recognition, including an illustration of using a Subset Knowledge resource.
The raw content recognizer of the iink SDK enables analyzing unstructured inks to separate parts that correspond to structured text and/or shapes and/or math from parts that do not.
The raw-content.classification.types
controls the list of content types that can be output by the ink strokes classifier. If content types are removed from this list, the corresponding strokes are output as part of the most likely alternative choice among the remaining content types.
The raw-content.recognition.types
defines the type of recognition that will be performed on this content and the result that will be available in the JIIX export.
The classification and recognition outputs are available in jiix output format with the application/vnd.myscript.jiix
mime type.
Please refer to the configuration guide for an exhaustive list of configuration options for the Raw Content recognition.
Here is an example of Raw Content recognition.
The shape recognizer enables the recognition of shapes only: no matter which ink content is sent to the Shape recognizer, it returns the shape(s) that it recognizes, with alternative recognized shape(s), if any.
By default, the shape beautification is enabled: the beautification process consists in aligning shapes with each other, connecting shapes that almost touch each other and scaling shapes having close sizes.
You can disabled the shape beautification with the shape.beautification.enable
.
The recognition output is available in jiix output format with the application/vnd.myscript.jiix
mime type.
Here is an example of Shape recognition.
The gesture recognizer is dedicated to the recognition of gestures without any text context.
The recognition output is available in jiix output format with the application/vnd.myscript.jiix
mime type.
Here is an example of Gesture recognition.