Page Summary
-
MLKTextRecognizeris a class used for recognizing text within images. -
It provides methods for both synchronous and asynchronous text recognition.
-
Developers can configure the recognizer with options like language preferences.
-
A
MLKTextobject is returned, containing the recognized text information. -
The older
textRecognizermethod is deprecated, favoringtextRecognizerWithOptionsfor configuration.
MLKTextRecognizer
@interface MLKTextRecognizer : NSObjectA text recognizer that recognizes text in an image.
-
Returns a text recognizer with the given options.
Concurrent usage of multiple
TextRecognizerinstances with different language options is not recommended, since it may lead to performance degradation.Declaration
Objective-C
+ (nonnull instancetype)textRecognizerWithOptions: (nonnull MLKCommonTextRecognizerOptions *)options;Parameters
optionsOptions for configuring the text recognizer.
Return Value
An text recognizer configured with the given options.
-
Processes the given image for text recognition.
Declaration
Objective-C
- (void)processImage:(nonnull id<MLKCompatibleImage>)image completion:(nonnull MLKTextRecognitionCallback)completion;Parameters
imageThe image to process.
completionHandler to call back on the main queue when text recognition completes.
-
Returns text recognition result in the given image or
nilif there was an error. The text recognition is performed synchronously on the calling thread.It is advised to call this method off the main thread to avoid blocking the UI. As a result, an
NSExceptionis raised if this method is called on the main thread.Declaration
Objective-C
- (nullable MLKText *)resultsInImage:(nonnull id<MLKCompatibleImage>)image error:(NSError *_Nullable *_Nullable)error;Parameters
imageThe image to get results in.
errorAn optional error parameter populated when there is an error getting results.
Return Value
Text recognition result in the given image or
nilif there was an error.
-
DEPRECATED. Use
textRecognizer(options:)instead.Returns a text recognizer for Latin-based languages.
Declaration
Objective-C
+ (nonnull instancetype)textRecognizer;Return Value
A text recognizer for Latin-based languages.