Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Real-Time OCR for Mobile Apps With RTR SDK

DZone's Guide to

Real-Time OCR for Mobile Apps With RTR SDK

ABBYY is bringing optical character recognition technology to your phone. This article will tell you how to take their image recognition app for a spin.

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

I remember the first time I tried the image recognition technology in the Google translate app, snapping a poster to instantly translate what it said into a language I understood. It was far from perfect, but it was cool, and it showed the potential of what more traditional optical character recognition could be used for.

ABBYY is a long-established company with a history in OCR technologies, but also more expected product lines such as business card readers, invoice scanners, and general purpose OCR products. Their new real-time recognition SDK brings the company into the world of real-time recognition, or to be more precise, bringing the technology to your apps. It’s not an open source SDK, but for early stage ideas, you will probably fall into the free bracket. With support for 46 languages and text on natural backgrounds, hopefully, it’s worth it.

The SDK is available for iOS and Android and there are plenty of examples and getting-started guides, so let’s take it for a spin. I am an Android user, so I will focus on that- sorry!

As is traditional (note, I say this as a professional technical writer, so I am fussy), documentation is a little confusing, but here’s how I got the sample app working:

  1. Download the SDK archive from the rtrsdk.com homepage, not the samples from GitHub as it contains everything you need.
  2. Unarchive that download.
  3. Change applicationId in build.gradle (Module: app).
  4. Copy the AbbyyRtrSdk.license file from License/ into the assets folder.
  5. Change the value of private static final String licenseFileName = "license"; in the MainActivity class to the name of the license file, AbbyyRtrSdk.license.
  6. Copy the assets folder into app/src/main of the sample code folder.
  7. Build and run! You will need to use a real device.

Here are my results:

First, a clear selection of English text, 100% accurate.

Image title


Second, a not-so-clear selection of German text- not too bad.

Image title

You can find more information on using the library in your own application in the official documentation, but here are a couple of useful principles to get you started.

You will need to allow for internet permissions in the Android manifest:

<uses-permissionandroid:name="android.permission.INTERNET"/>

To reduce application size, remove dictionaries from the assets/dictionairies folder, and from the on-screen toggle menu by removing entries in:

privateLanguage[]languages={
Language.English,
Language.German,
};

You can access the text results in the following callback:

@Override
publicvoidonFrameProcessed(ITextCaptureService.TextLine[] lines,
ITextCaptureService.ResultStabilityStatus resultStatus,ITextCaptureService.Warning warning )
{

}

Checking the reliability of the results from resultStatus, an enum value represented by the colored dots in my screenshots above:

enumResultStabilityStatus{
NotReady,
Tentative,
Verified,
Available,
TentativelyStable,
Stable
};

Then, assessing the text from lines, an array of each line of text recognized that also contains details of the bounding rectangle surrounding the text.

And that’s it. The SDK is simple to use, but behind it lies a lot of complex processing that you can take advantage of. It’s currently available in Australia and New Zealand, but by the time you read this, should be available globally.

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:
ocr ,mobile ,real-time ,text recognition ,ios ,android ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}