Recognize Text on Photos and Images: iOS

Documentation Menu

This guide explains how Real-Time Recognition SDK can be used as a common OCR solution, recognizing text on existing images.

note Note: This feature is available only in the extended version of the library.

How it Works

Real-Time Recognition SDK provides access to single image processing functions, enabling the generic OCR functionality. This scenario works with any image file you can load to memory. It does not require access to the camera on the device.


note Note: Before you begin, see Build your application with the OCR library for iOS.

To implement the image recognition scenario, follow these steps:

  1. Create an RTREngine object using the sharedEngineWithLicenseData: method. The method requires an NSData object containing your license data. For example, you can use dataWithContentsOfFile: to create a data object, then pass this object to the sharedEngineWithLicenseData: method.
  2. Use the createCoreAPImethod of the RTREngine object to create a recognizer object which conforms to the RTRCoreAPI protocol.
  3. If you want to change recognition settings, use the textRecognitionSettings property of the recognizer object (RTRCoreAPITextRecognitionSettings protocol).
    • If you are using a recognition language different from English, specify it using the setRecognitionLanguages: method. Multiple languages are also supported, although setting too many languages may decrease recognition performance.
    • It is also recommended to call the setAreaOfInterest: method to specify the rectangular area of the image where to search for text. For example, your application may provide controls that allow user to select a smaller part of image for recognition if needed. Also, best results are achieved when the area of interest does not cover the whole image but has a margin of at least half the size of a typical printed character.
  4. The processingSettings property of the recognizer object (RTRCoreAPIProcessingSettings protocol) allows you to set the number of processing threads.
  5. Recognition starts with a call to the recognizeText:onProgress:onTextOrientationDetected:error: method. It requires you to implement the following callbacks (passed as arguments to this method):
    • A progress callback (onProgress) that receives estimated completion percentage and warnings. This callback should return a BOOL value. The return value can be used to interrupt processing: return TRUE to terminate the current operation, FALSE to continue.
    • A callback that informs you when the image orientation is detected (onTextOrientationDetected).
    • A callback to handle errors (error).
  6. When finished, the recognizeText:onProgress:onTextOrientationDetected:error: method will return an array of RTRTextBlock objects which contain the results of recognition for the text areas found on the image. Each RTRTextBlock is an array containing one or more text lines represented by RTRTextLine objects. Each RTRTextLine contains information about the enclosing quadrangle for a single line of text and the recognized text.
    Work with the results on your side.

See the description of classes and methods in the API Reference section.