MLKitDigitalInkRecognition Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
DigitalInkRecognizer
class DigitalInkRecognizer : NSObject
Object to perform handwriting recognition on digital ink.
Digital ink is the vector representation of what a user has written. It is composed of a sequence
of strokes, each being a sequence of touch points (coordinates and timestamp). See Ink
for
details.
-
-
Declaration
Swift
class func digitalInkRecognizer(options: MLKDigitalInkRecognizerOptions) -> DigitalInkRecognizer
-
Performs a recognition of the input ink.
Note that using recognize(ink:context:completion:)
instead of this method may lead to better
accuracy in some cases.
Declaration
Swift
func recognize(ink: MLKInk) async throws -> MLKDigitalInkRecognitionResult
-
Performs a recognition of the input ink using a recognition context.
A recognition context contains information about the size of the writing area, and the characters
that have already been entered in the text area. This helps disambiguate certain cases.
Example usage: a previous recognition has yielded the string “hello”, that has been inserted in a
text field. The user then handwrites “world”. Send the present method the ink showing “world”,
and “hello” as a string in context
. The recognizer will most likely return the string “ world”
with a leading space separating the two words.
See DigitalInkRecognitionContext
for details.
Declaration
Swift
func recognize(ink: MLKInk, context: MLKDigitalInkRecognitionContext) async throws -> MLKDigitalInkRecognitionResult
Parameters
ink
|
|
context
|
|
completion
|
A callback for returning recognition candidates. See
DigitalInkRecognizerCallback for details. If nothing can be recognized, an empty list of
candidates will be passed to the callback.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eDigitalInkRecognizer\u003c/code\u003e is an object used for performing handwriting recognition on digital ink, which is a vector representation of user writing composed of strokes and touch points.\u003c/p\u003e\n"],["\u003cp\u003eIt is initialized using \u003ccode\u003edigitalInkRecognizer(options:)\u003c/code\u003e with specified options for customization.\u003c/p\u003e\n"],["\u003cp\u003eThe primary functions are \u003ccode\u003erecognize(ink:)\u003c/code\u003e and \u003ccode\u003erecognize(ink:context:)\u003c/code\u003e for performing handwriting recognition, with the latter allowing for a recognition context to improve accuracy.\u003c/p\u003e\n"],["\u003cp\u003eUsing a \u003ccode\u003eDigitalInkRecognitionContext\u003c/code\u003e with \u003ccode\u003erecognize(ink:context:)\u003c/code\u003e can provide better accuracy by considering the writing area and pre-existing text.\u003c/p\u003e\n"]]],[],null,["# MLKitDigitalInkRecognition Framework Reference\n\nDigitalInkRecognizer\n====================\n\n class DigitalInkRecognizer : NSObject\n\nObject to perform handwriting recognition on digital ink.\n\nDigital ink is the vector representation of what a user has written. It is composed of a sequence\nof strokes, each being a sequence of touch points (coordinates and timestamp). See [Ink](../Classes/Ink.html) for\ndetails.\n- `\n ``\n ``\n `\n\n ### [-init](#/c:objc(cs)MLKDigitalInkRecognizer(im)init)\n\n `\n ` \n Unavailable. Use [digitalInkRecognizer(options:)](../Classes/DigitalInkRecognizer.html#/c:objc(cs)MLKDigitalInkRecognizer(cm)digitalInkRecognizerWithOptions:) instead.\n- `\n ``\n ``\n `\n\n ### [digitalInkRecognizer(options:)](#/c:objc(cs)MLKDigitalInkRecognizer(cm)digitalInkRecognizerWithOptions:)\n\n `\n ` \n Creates a `DigitalInkRecognizer` object using the specified options.\n\n See [DigitalInkRecognizerOptions](../Classes/DigitalInkRecognizerOptions.html) for details. \n\n #### Declaration\n\n Swift \n\n class func digitalInkRecognizer(options: MLKDigitalInkRecognizerOptions) -\u003e DigitalInkRecognizer\n\n- `\n ``\n ``\n `\n\n ### [recognize(ink:)](#/c:objc(cs)MLKDigitalInkRecognizer(im)recognizeInk:completion:)\n\n `\n ` \n Performs a recognition of the input ink.\n\n Note that using `recognize(ink:context:completion:)` instead of this method may lead to better\n accuracy in some cases. \n\n #### Declaration\n\n Swift \n\n func recognize(ink: MLKInk) async throws -\u003e MLKDigitalInkRecognitionResult\n\n #### Parameters\n\n |--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*ink*` ` | Input to be recognized. |\n | ` `*completion*` ` | A callback for returning recognition candidates. See [DigitalInkRecognizerCallback](../Type-Definitions.html#/c:MLKDigitalInkRecognizer.h@T@MLKDigitalInkRecognizerCallback) for details. |\n\n- `\n ``\n ``\n `\n\n ### [recognize(ink:context:)](#/c:objc(cs)MLKDigitalInkRecognizer(im)recognizeInk:context:completion:)\n\n `\n ` \n Performs a recognition of the input ink using a recognition context.\n\n A recognition context contains information about the size of the writing area, and the characters\n that have already been entered in the text area. This helps disambiguate certain cases.\n\n Example usage: a previous recognition has yielded the string \"hello\", that has been inserted in a\n text field. The user then handwrites \"world\". Send the present method the ink showing \"world\",\n and \"hello\" as a string in `context`. The recognizer will most likely return the string \" world\"\n with a leading space separating the two words.\n\n See [DigitalInkRecognitionContext](../Classes/DigitalInkRecognitionContext.html) for details. \n\n #### Declaration\n\n Swift \n\n func recognize(ink: MLKInk, context: MLKDigitalInkRecognitionContext) async throws -\u003e MLKDigitalInkRecognitionResult\n\n #### Parameters\n\n |--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*ink*` ` | Input to be recognized. |\n | ` `*context*` ` | See [DigitalInkRecognitionContext](../Classes/DigitalInkRecognitionContext.html) for details. |\n | ` `*completion*` ` | A callback for returning recognition candidates. See [DigitalInkRecognizerCallback](../Type-Definitions.html#/c:MLKDigitalInkRecognizer.h@T@MLKDigitalInkRecognizerCallback) for details. If nothing can be recognized, an empty list of candidates will be passed to the callback. |"]]