Developer's Documentation for free mobile OCR SDK

Documentation Menu

Recognize Text on Photos and Images: Android

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.

Implementation

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

To implement the image recognition scenario, follow these steps:

  1. Begin with the TextRecognitionCallback interface implementation. Its methods will be used to get status information and control the recognition process. Here are the brief recommendations on what the methods should do:
    • The onProgress method is used to report recognition status. It also allows you to interrupt the recognition process.
    • The onTextOrientationDetected is called when image orientation (or change in orientation) is detected.
    • The onError method is for handling processing errors.
  2. Call the Engine.load method to create an engine object via which all other objects may be created. This object should be reused for every new operation and should not be created again in the same activity.
  3. Use the createRecognitionCoreAPI method of the Engine object to create a recognizer object (implementing the IRecognitionCoreAPI interface). Use this object on the thread on which it was created; you may also create several objects on different threads and use them concurrently. All IRecognitionCoreAPI interface method calls are synchronous (will not return until the operation is completed), so the recognizer should not be used on the UI thread.
  4. If you want to change recognition settings, use IRecognitionCoreAPI.getTextRecognitionSettings to get a TextRecognitionSettings object, then use its methods to set the recognition area and text language.
    • If you are using a recognition language different from English, specify it using the TextRecognitionSettings.setRecognitionLanguage method. Multiple languages are also supported, although setting too many languages may decrease recognition performance.
    • It is also recommended to call the TextRecognitionSettings.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.
  5. You can also set the number of processing threads using the object returned by IRecognitionCoreAPI.getProcessingSettings (ProcessingSettings interface).
  6. To start recognition, call the recognizeText method of the IRecognitionCoreAPI interface. Its required input parameters are the bitmap to process and your TextRecognitionCallback object. The recognizer will start up several working threads and continue interacting with your application via the TextRecognitionCallback interface.
  7. When finished, the recognizeText method will return an array of TextBlock objects which contain the results of recognition for the text areas found on the image. Each TextBlock contains one or more text lines represented by TextLine objects. Each TextLine contains information about the enclosing quadrangle for a single line of text and the recognized text as a string.
    Work with the results on your side.
  8. When pausing or quitting the application, call the IRecognitionCoreAPI.close method to release resources.

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