Click here to Skip to main content
15,867,330 members
Articles / Mobile Apps / iOS
Article

Multi-Platform OCR with LEADTOOLS 18

1 Feb 2013CPOL2 min read 37.5K   7   5
Multi-Platform OCR with LEADTOOLS 18.

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

Introduction

With the release of LEADTOOLS Version 18, also known as LEADTOOLS Anywhere™, LEAD Technologies has expanded its reach as the world’s leading imaging SDK by providing new multi-platform imaging libraries for iOS, OS X, Android and Linux. Viewers, annotations and markups, OCR, barcode, PDF, image formats, compression, image processing and more are just a sampling of what LEADTOOLS has to offer any developer, not just those targeting Windows.

Programmers using LEADTOOLS can experience a set of libraries that closely resemble each other on every development platform. This is a distinct advantage for developers whose goal is to create native versions of their apps on multiple platforms. Even if your plan is to develop for a single platform, LEADTOOLS provides a programmer friendly interface for every major platform out there, and the flexibility and peace of mind to easily expand in the future.

Key Features in LEADTOOLS Anywhere™ SDKs

  • Image Viewer Controls designed specifically for .NET, HTML5, WinRT, iOS, OS X and Android
  • Load, convert and save more than 150 image formats
    • Advanced bit depth, color space and compression support for common formats including PDF, PDF/A, JPEG, JPEG 2000, TIFF, JBIG2 and more
  • OCR to convert images to searchable text, PDF and DOC
  • Barcode reading and writing for QR, PDF417, Data Matrix, UPC/EAN and more
  • Comprehensive Annotation and Markup including geometric shapes, sticky note, redact, highlight and rubber stamp
  • Over 200 Image processing functions for enhancing, correcting and manipulating images

The OCR Code

In the examples that follow, we’ll show how to convert a platform-native image into a LEADTOOLS RasterImage, and then use the OCR engine to extract the searchable text. Alternatively, developers can use the RasterCodecs object to load and save their images. However, using LEAD’s conversion utilities is a powerful asset for existing applications because it requires minimal changes to your current code base.

.NET

C#
System.Drawing.Bitmap bitmap = ... // 
// Get a LEADTOOLS RasterImage from the platform image
RasterImage rasterImage = RasterImageConverter.FromImage(bitmap);
// Create a LEADTOOLS OCR Document instance
IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineAdvantage, false);
ocrEngine.Startup(null, null, null, Application.CommonAppDataPath);
IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument();
// Add the page to the document and recognize it
IOcrPage ocrPage = ocrDocument.Pages.AddPage(rasterImage, null);
// Recognize the image as text
string text = ocrPage.RecognizeText(null);
// Do something with 'text'

Image 1

WinRT

C#
Windows.UI.Xaml.Media.ImageSource imageSource = ... //
// Get a LEADTOOLS RasterImage from the platform image
RasterImage rasterImage = RasterImageConverter.ConvertFromImageSource(imageSource, ConvertFromImageOptions.None);
// Create a LEADTOOLS OCR Document instance
IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false);
ocrEngine.Startup(null, null, string.Empty, Package.Current.InstalledLocation.Path);
IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument();
// Add the page to the document and recognize it
IOcrPage ocrPage = ocrDocument.Pages.AddPage(rasterImage, null);
// Recognize the image as text
string text = ocrPage.RecognizeText(null);
// Do something with 'text'

Image 2

iOS & OS X

UIImage* uiImage = ... //
// Get a LEADTOOLS RasterImage from the platform image
LTRasterImage* rasterImage = [LTRasterImageConverter convertFromImage:uiImage
     options:LTConvertFromImageOptions_None
       error:nil];
// Create a LEADTOOLS OCR Document instance
[ocrEngine startup:nil workDirectory:nil startupParameters:[[NSBundle mainBundle] bundlePath];
LTOcrDocument* ocrDocument = [ocrEngine.documentManager createDocument];
// Add the page to the document and recognize it
LTOcrPage* ocrPage = [ocrDocument.pages addPageWithImage:rasterImage
   target:nil
   selector:nil
   error:nil];
// Recognize the image as text
NSString* text = [ocrPage recognizeText:nil selector:nil error:nil];
// Do something with 'text'

Image 3

Android

Java
android.graphics.Bitmap bitmap = ... //
// Get a LEADTOOLS RasterImage from the platform image
RasterImage rasterImage = RasterImageConverter.convertFromBitmap(bitmap, ConvertFromImageOptions.NONE);
// Create a LEADTOOLS OCR Document instance
OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.Advantage);
ocrEngine.startup(null, "", null, this.getApplicationInfo().dataDir);
OcrDocument document = ocrEngine.getDocumentManager().createDocument();
// Add the page to the document and recognize it
OcrPage ocrPage = document.getPages().addPage(image, null);
// Recognize the image as text
String text = ocrPage.recognizeText(this);
// Do something with 'text'

Image 4

Download the Full Examples

You can download fully functional demos which includes the features discussed above. To run these examples you will need the following:

Support

Need help getting this sample up and going? Contact our support team for free technical support! For pricing or licensing questions, you can contact our sales team (sales@leadtools.com) or call us at 704-332-5532.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Help desk / Support LEAD Technologies, Inc.
United States United States
Since 1990, LEAD has established itself as the world's leading provider of software development toolkits for document, medical, multimedia, raster and vector imaging. LEAD's flagship product, LEADTOOLS, holds the top position in every major country throughout the world and boasts a healthy, diverse customer base and strong list of corporate partners including some of the largest and most influential organizations from around the globe. For more information, contact sales@leadtools.com or support@leadtools.com.
This is a Organisation (No members)


Comments and Discussions

 
QuestionMultimedia SDK??? Pin
xirisjohn27-Feb-13 10:41
xirisjohn27-Feb-13 10:41 
Is there an 18.0 release of the Multimedia SDK? I understand it does (will) support HTML5 video streaming...
AnswerRe: Multimedia SDK??? Pin
LEADTOOLS Support7-Mar-13 3:32
sponsorLEADTOOLS Support7-Mar-13 3:32 
QuestionLines Pin
cocis4814-Feb-13 7:27
cocis4814-Feb-13 7:27 
QuestionDocument scanner Pin
cocis487-Feb-13 9:32
cocis487-Feb-13 9:32 
AnswerRe: Document scanner Pin
LEADTOOLS Support11-Feb-13 3:24
sponsorLEADTOOLS Support11-Feb-13 3:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.