Skip to content
This repository has been archived by the owner. It is now read-only.
Tesseract OCR for iOS
C++ C Other
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.
tesseract-ios-lib Add 'tesseract-ios-lib/' from commit '119c71c8af4a76fa97623dc0de3d622… Feb 28, 2014

Tesseract for iOS

tesseract-ios is not actively maintained anymore. I encourage you to use gali8's Tesseract-OCR-iOS instead.


Tesseract-ios is an Objective-C wrapper for Tesseract OCR.

This project couldn't exist without the Ângelo Suzuki's blog post. A lot of code came from his article.


  • iOS SDK 6.0, iOS 5.0+ (there is no support for armv6)
  • Tesseract and Leptonica libraries from the tesseract-ios-lib repo.


  • Add tesseract-ios as a group, and tessdata by reference to your project:

  • Go to your project settings, and ensure that C++ Standard Library => libstdc++:


Here is the default workflow to extract text from an image:

  • Instantiate Tesseract with data path and language
  • Set variables (character set, …)
  • Set the image to analyze
  • Start recognition
  • Get recognized text
  • Clear

Code Sample

#import "Tesseract.h"

Tesseract* tesseract = [[Tesseract alloc] initWithDataPath:@"tessdata" language:@"eng"];
[tesseract setVariableValue:@"0123456789" forKey:@"tessedit_char_whitelist"];
[tesseract setImage:[UIImage imageNamed:@"image_sample.jpg"]];
[tesseract recognize];

NSLog(@"%@", [tesseract recognizedText]);
[tesseract clear];

Method reference


- (id)initWithDataPath:(NSString *)dataPath language:(NSString *)language

Initialize a new Tesseract instance.

  • dataPath: a relative path from the application bundle to the .traineddata files. You can find these files from the tesseract downloads section.
  • language: language used for recognition. Ex: eng. Tesseract will search for a eng.traineddata file in the dataPath directory.

Returns nil if instanciation failed.


- (void)setVariableValue:(NSString *)value forKey:(NSString *)key

Set Tesseract variable key to value. See for a complete (but not up-to-date) list.

For instance, use tessedit_char_whitelist to restrict characters to a specific set.


- (void)setImage:(UIImage *)image

Set the image to recognize.


- (BOOL)setLanguage:(NSString *)language

Override the language defined with -initWithDataPath:language:.


- (BOOL)recognize

Start text recognition. You might want to launch this process in background with NSObject's -performSelectorInBackground:withObject:.


- (NSString *)recognizedText

Get the text extracted from the image.


- (void) clear

Clears Tesseract object after text has been recognized from image. Preventing memory leaks.

You can’t perform that action at this time.