Skip to content

Commit

Permalink
Tesseracto for iOS 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniele authored and Daniele committed Jan 22, 2014
1 parent c8feb44 commit 2d71254
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@

@property (nonatomic, weak) id<TesseractDelegate> delegate;

- (id)initWithDataPath:(NSString *)dataPath language:(NSString *)language; //designed
///
/// @warning deprecated method!
/// @deprecated - (id)initWithDataPath:(NSString *)dataPath language:(NSString *)language is deprecated. Please use - (id)initWithLanguage:(NSString*)language;
///
- (id)initWithDataPath:(NSString *)dataPath language:(NSString *)language DEPRECATED_ATTRIBUTE;
- (id)initWithLanguage:(NSString*)language;
- (void)setVariableValue:(NSString *)value forKey:(NSString *)key;

Expand Down
Binary file modified Products/TesseractOCR.framework/Versions/A/Resources/Info.plist
Binary file not shown.
Binary file modified Products/TesseractOCR.framework/Versions/A/TesseractOCR
Binary file not shown.
87 changes: 45 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
Tesseract OCR iOS 1.61 (iOS7 ready & arm64 ready)
Tesseract OCR iOS 2 (iOS7 ready & arm64 ready)
=================

**Tesseract OCR iOS is a Framework for iOS5+.**

It will help you to use OCR in iOS projects. Easy and fast.
It helps you to use OCR in iOS projects, writing Objective-C. Easy and fast.

<br/>
Template Framework Project
=================
You can use the "**Template Framework Project**". It's a starting point for use the Tesseract Framework. It's iOS7 and arm64 ready!

Into the tessdata folder (linked like a referenced folder into the project), there are the .traineddata language files.

Alternatively you can create a **New Project** like explained below.

New Framework Project
Expand All @@ -25,12 +27,16 @@ If you are masochist :) you can generate your TesseractOCR.framework building th

- Go to your project settings, and ensure that C++ Standard Library => Compiler Default. (thanks to https://github.com/trein)

- Import the <code>tessdata</code> folder under the root of your project. It contains the "tessdata" files. You can add more tessdata files copyng them here.
- Copy and import the <code>tessdata</code> folder from the Template Framework Project under the root of your project. It contains the "tessdata" files. You can add more tessdata files copyng them here.

WARNING: Check the "Create folder references for any added folders" option and the correct target into the "Add to Targets" section.

<img src="https://www.dropbox.com/s/0a33kuuasuxlp4k/tessdata%20folder.png" />


- Import the header in your classes writing <code>#import &lt;TesseractOCR/TesseractOCR.h&gt;</code>

Now you can use Tesseract class like explained here: https://github.com/ldiqual/
tesseract-ios
Now you can use Tesseract class like explained below:

<br/>
How to use
Expand All @@ -47,38 +53,31 @@ How to use
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

Tesseract* tesseract = [[Tesseract alloc] initWithDataPath:@"tessdata" language:@"<strong>eng+ita</strong>"];

// language are used for recognition. Ex: eng. Tesseract will search for a eng.traineddata file in the dataPath directory.
// eng.traineddata is in your "tessdata" folder.
// Assumed, that you added a group "tessdata" into your xCode project tree and .traineddata files to it.
// This actually will not create a "tessdata" folder into your application bundle. Instead, all the files would be located into the root of the bundle.
// This initializer will copy such 'traineddata' files located in the root folder of the application bundle to 'Documents/traneddata' folder of the application bundle to allow Tesseract to searcj for files into "tessdata".
// This leads to two copies of the same huge files on user's disk.

// If you'd like to avoid wasting user's disk space, pls, import the whole tessdata folder as a refernce to your project
// with the ‘Create folder references for any added folders’ options set up in the «Add files to project» dialog
// (In such case a folder in the xCode project tree will look blue instead of yellow).
// So use the following initializer instead
// Tesseract* tesseract = [[Tesseract alloc] initWithDataPath:nil language:@"<strong>eng+ita</strong>"];
// or

// language are used for recognition. Ex: eng. Tesseract will search for a eng.traineddata file in the dataPath directory; eng+ita will search for a eng.traineddata and ita.traineddata.

//Like in the Template Framework Project:
// Assumed that .traineddata files are in your "tessdata" folder and the folder is in the root of the project.
// Assumed, that you added a folder references "tessdata" into your xCode project tree, with the ‘Create folder references for any added folders’ options set up in the «Add files to project» dialog.
// Assumed that any .traineddata files is in the tessdata folder, like in the Template Framework Project

//Create your tesseract using the initWithLanguage method:
// Tesseract* tesseract = [[Tesseract alloc] initWithLanguage:@"<strong>eng+ita</strong>"];

// set up the delegate to recieve tesseract's callback
// self should respond to TesseractDelegate and implement shouldCancelImageRecognitionForTesseract: method
// to have an ability to recieve callback and interrupt Tesseract before it finishes

tesseract.delegate = self;

[tesseract setVariableValue:@"0123456789" forKey:@"tessedit_char_whitelist"]; //limit search
[tesseract setImage:[UIImage imageNamed:@"image_sample.jpg"]]; //image to check
[tesseract recognize];

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

[tesseract clear];

// set up the delegate to recieve tesseract's callback
// self should respond to TesseractDelegate and implement shouldCancelImageRecognitionForTesseract: method
// to have an ability to recieve callback and interrupt Tesseract before it finishes

Tesseract* tesseract = [[Tesseract alloc] initWithLanguage:@"eng+ita"];
tesseract.delegate = self;

[tesseract setVariableValue:@"0123456789" forKey:@"tessedit_char_whitelist"]; //limit search
[tesseract setImage:[UIImage imageNamed:@"image_sample.jpg"]]; //image to check
[tesseract recognize];

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

[tesseract clear];
}


Expand All @@ -97,6 +96,16 @@ For instance, use tessedit_char_whitelist to restrict characters to a specific s
<br/>
Updates in this version
=================
- New release 2.0 with 64 bit support.

- The - (id)initWithDataPath:(NSString * *)dataPath language:(NSString * *)language method is now deprecated.

- Bug fixing!

- Removed tessdata folder from the framework project.

- The tessdata folder (follow the Template Framework Project) is now linked with the "folder references" option into the Template Project. <strong>REQUIRED!!!</strong>

- Added delegate TesseractDelegate

- arm64 support. Thanks to Cyril
Expand Down Expand Up @@ -131,14 +140,8 @@ License

Tesseract OCR iOS and TesseractOCR.framework are under MIT License.

Tesseract-ios, powered by ldiqual https://github.com/ldiqual/tesseract-ios, is under MIT License.

Tesseract, powered by Google http://code.google.com/p/tesseract-ocr/, is under Apache License.

Thanks
=================

Thanks to ldiqual for the good wrapper for Tesseract.

Author Infos
=================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
6400DDE3180C5DE000443362 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6400DDE1180C5DE000443362 /* InfoPlist.strings */; };
6400DDE5180C5DE000443362 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6400DDE4180C5DE000443362 /* main.m */; };
6400DDE9180C5DE000443362 /* G8AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6400DDE8180C5DE000443362 /* G8AppDelegate.m */; };
6400DDEC180C5DE000443362 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6400DDEA180C5DE000443362 /* Main.storyboard */; };
6400DDEF180C5DE000443362 /* G8ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6400DDEE180C5DE000443362 /* G8ViewController.m */; };
6400DDF1180C5DE000443362 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6400DDF0180C5DE000443362 /* Images.xcassets */; };
6400DE1D180C5FBE00443362 /* eng.traineddata in Resources */ = {isa = PBXBuildFile; fileRef = 6400DE19180C5FBE00443362 /* eng.traineddata */; };
6400DE1E180C5FBE00443362 /* equ.traineddata in Resources */ = {isa = PBXBuildFile; fileRef = 6400DE1A180C5FBE00443362 /* equ.traineddata */; };
6400DE1F180C5FBE00443362 /* grc.traineddata in Resources */ = {isa = PBXBuildFile; fileRef = 6400DE1B180C5FBE00443362 /* grc.traineddata */; };
6400DE20180C5FBE00443362 /* ita.traineddata in Resources */ = {isa = PBXBuildFile; fileRef = 6400DE1C180C5FBE00443362 /* ita.traineddata */; };
6420626F1846105200EE2AD4 /* TesseractOCR.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6420626E1846105200EE2AD4 /* TesseractOCR.framework */; };
64DDA74E188FD7D10025590D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6400DDEA180C5DE000443362 /* Main.storyboard */; };
64DDA75B188FD9140025590D /* tessdata in Resources */ = {isa = PBXBuildFile; fileRef = 64DDA75A188FD9140025590D /* tessdata */; };
64E40AB1180C6D4D00C36DDE /* libstdc++.6.0.9.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 64E40AB0180C6D4D00C36DDE /* libstdc++.6.0.9.dylib */; };
/* End PBXBuildFile section */

Expand All @@ -42,11 +39,8 @@
6400DDEE180C5DE000443362 /* G8ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = G8ViewController.m; sourceTree = "<group>"; };
6400DDF0180C5DE000443362 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
6400DDF7180C5DE000443362 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
6400DE19180C5FBE00443362 /* eng.traineddata */ = {isa = PBXFileReference; lastKnownFileType = file; path = eng.traineddata; sourceTree = "<group>"; };
6400DE1A180C5FBE00443362 /* equ.traineddata */ = {isa = PBXFileReference; lastKnownFileType = file; path = equ.traineddata; sourceTree = "<group>"; };
6400DE1B180C5FBE00443362 /* grc.traineddata */ = {isa = PBXFileReference; lastKnownFileType = file; path = grc.traineddata; sourceTree = "<group>"; };
6400DE1C180C5FBE00443362 /* ita.traineddata */ = {isa = PBXFileReference; lastKnownFileType = file; path = ita.traineddata; sourceTree = "<group>"; };
6420626E1846105200EE2AD4 /* TesseractOCR.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TesseractOCR.framework; path = ../Products/TesseractOCR.framework; sourceTree = "<group>"; };
64DDA75A188FD9140025590D /* tessdata */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tessdata; sourceTree = "<group>"; };
64E40AB0180C6D4D00C36DDE /* libstdc++.6.0.9.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libstdc++.6.0.9.dylib"; path = "usr/lib/libstdc++.6.0.9.dylib"; sourceTree = SDKROOT; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -99,7 +93,7 @@
6400DDDE180C5DE000443362 /* Template Framework Project */ = {
isa = PBXGroup;
children = (
6400DE18180C5FBE00443362 /* tessdata */,
64DDA75A188FD9140025590D /* tessdata */,
6400DDE7180C5DE000443362 /* G8AppDelegate.h */,
6400DDE8180C5DE000443362 /* G8AppDelegate.m */,
6400DDEA180C5DE000443362 /* Main.storyboard */,
Expand All @@ -123,18 +117,6 @@
name = "Supporting Files";
sourceTree = "<group>";
};
6400DE18180C5FBE00443362 /* tessdata */ = {
isa = PBXGroup;
children = (
6400DE19180C5FBE00443362 /* eng.traineddata */,
6400DE1A180C5FBE00443362 /* equ.traineddata */,
6400DE1B180C5FBE00443362 /* grc.traineddata */,
6400DE1C180C5FBE00443362 /* ita.traineddata */,
);
name = tessdata;
path = ../../TesseractOCR/tessdata;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -188,14 +170,11 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6400DE1D180C5FBE00443362 /* eng.traineddata in Resources */,
6400DDF1180C5DE000443362 /* Images.xcassets in Resources */,
6400DE20180C5FBE00443362 /* ita.traineddata in Resources */,
428615B71845F340005D5A2E /* image_sample.jpg in Resources */,
6400DE1E180C5FBE00443362 /* equ.traineddata in Resources */,
64DDA75B188FD9140025590D /* tessdata in Resources */,
6400DDE3180C5DE000443362 /* InfoPlist.strings in Resources */,
6400DE1F180C5FBE00443362 /* grc.traineddata in Resources */,
6400DDEC180C5DE000443362 /* Main.storyboard in Resources */,
64DDA74E188FD7D10025590D /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
#import "G8ViewController.h"

@interface G8ViewController ()

{

}
@end

@implementation G8ViewController

/****README****/
/*
tessdata group is linked into the template project, from the main project.
Tessdata folder is into the template project..
TesseractOCR.framework is linked into the template project under the Framework group. It's builded by the main project.
If you are using iOS7 or greater, import libstdc++.6.0.9.dylib (not libstdc++)!!!!!
Expand All @@ -29,29 +31,22 @@ @implementation G8ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

Tesseract* tesseract = [[Tesseract alloc] initWithDataPath:@"tessdata" language:@"eng+ita"];

// language are used for recognition. Ex: eng. Tesseract will search for a eng.traineddata file in the dataPath directory.
// eng.traineddata is in your "tessdata" folder.
// Assumed, that you added a group "tessdata" into your xCode project tree and .traineddata files to it.
// This actually will not create a "tessdata" folder into your application bundle. Instead, all the files would be located into the root of the bundle.
// This initializer will copy such 'traineddata' files located in the root folder of the application bundle to 'Documents/traneddata' folder of the application bundle to allow Tesseract to searcj for files into "tessdata".
// This leads to two copies of the same huge files on user's disk.
// language are used for recognition. Ex: eng. Tesseract will search for a eng.traineddata file in the dataPath directory; eng+ita will search for a eng.traineddata and ita.traineddata.

// If you'd like to avoid wasting user's disk space, pls, import the whole tessdata folder as a refernce to your project
// with the ‘Create folder references for any added folders’ options set up in the «Add files to project» dialog
// (In such case a folder in the xCode project tree will look blue instead of yellow).
// So use the following initializer instead
// Tesseract* tesseract = [[Tesseract alloc] initWithDataPath:nil language:@"eng+ita"];
// or
// Tesseract* tesseract = [[Tesseract alloc] initWithLanguage:@"eng+ita"];
//Like in the Template Framework Project:
// Assumed that .traineddata files are in your "tessdata" folder and the folder is in the root of the project.
// Assumed, that you added a folder references "tessdata" into your xCode project tree, with the ‘Create folder references for any added folders’ options set up in the «Add files to project» dialog.
// Assumed that any .traineddata files is in the tessdata folder, like in the Template Framework Project

//Create your tesseract using the initWithLanguage method:
// Tesseract* tesseract = [[Tesseract alloc] initWithLanguage:@"<strong>eng+ita</strong>"];

// set up the delegate to recieve tesseract's callback
// self should respond to TesseractDelegate and implement shouldCancelImageRecognitionForTesseract: method
// to have an ability to recieve callback and interrupt Tesseract before it finishes

Tesseract* tesseract = [[Tesseract alloc] initWithLanguage:@"eng+ita"];
tesseract.delegate = self;

[tesseract setVariableValue:@"0123456789" forKey:@"tessedit_char_whitelist"]; //limit search
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.21</string>
<string>2.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 0 additions & 16 deletions Tesseract OCR iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
644EBBE417384A0B009A0759 /* equ.traineddata */ = {isa = PBXFileReference; lastKnownFileType = file; path = equ.traineddata; sourceTree = "<group>"; };
645C864A18698EBA00B27B19 /* README_howto_compile_libaries.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README_howto_compile_libaries.md; sourceTree = "<group>"; };
645C864D18698ECE00B27B19 /* build_dependencies.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = build_dependencies.sh; sourceTree = "<group>"; };
646772C318083B5600C85662 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README.md; path = ../README.md; sourceTree = "<group>"; };
Expand Down Expand Up @@ -338,12 +337,9 @@
64A029D117307CD0002B12E7 /* liblept.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = liblept.a; sourceTree = "<group>"; };
64A029D217307CD0002B12E7 /* libtesseract_all.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libtesseract_all.a; sourceTree = "<group>"; };
64A029D317307CD0002B12E7 /* README_tesseract.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README_tesseract.md; sourceTree = "<group>"; };
64A029D517307CD0002B12E7 /* grc.traineddata */ = {isa = PBXFileReference; lastKnownFileType = file; path = grc.traineddata; sourceTree = "<group>"; };
64A029D617307CD0002B12E7 /* Tesseract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tesseract.h; sourceTree = "<group>"; };
64A029D717307CD0002B12E7 /* Tesseract.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Tesseract.mm; sourceTree = "<group>"; };
64A029DD17307CED002B12E7 /* TesseractOCR.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TesseractOCR.h; sourceTree = "<group>"; };
64A5F311173867FC001622C1 /* eng.traineddata */ = {isa = PBXFileReference; lastKnownFileType = file; path = eng.traineddata; sourceTree = "<group>"; };
64A5F312173867FC001622C1 /* ita.traineddata */ = {isa = PBXFileReference; lastKnownFileType = file; path = ita.traineddata; sourceTree = "<group>"; };
64E40AA3180C6AA400C36DDE /* Template Framework Project.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "Template Framework Project.xcodeproj"; path = "Template Framework Project/Template Framework Project.xcodeproj"; sourceTree = "<group>"; };
64F74CCC172FD75F0068E657 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
64F74D77172FD8E90068E657 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -374,7 +370,6 @@
64A0293E17307CCF002B12E7 /* include */,
64A029D017307CD0002B12E7 /* lib */,
64A029D317307CD0002B12E7 /* README_tesseract.md */,
64A029D417307CD0002B12E7 /* tessdata */,
64A0293017307C1D002B12E7 /* Supporting Files */,
);
path = TesseractOCR;
Expand Down Expand Up @@ -565,17 +560,6 @@
path = lib;
sourceTree = "<group>";
};
64A029D417307CD0002B12E7 /* tessdata */ = {
isa = PBXGroup;
children = (
64A5F311173867FC001622C1 /* eng.traineddata */,
64A5F312173867FC001622C1 /* ita.traineddata */,
644EBBE417384A0B009A0759 /* equ.traineddata */,
64A029D517307CD0002B12E7 /* grc.traineddata */,
);
path = tessdata;
sourceTree = "<group>";
};
64E40AA4180C6AA400C36DDE /* Products */ = {
isa = PBXGroup;
children = (
Expand Down
Loading

0 comments on commit 2d71254

Please sign in to comment.