├── External ├── tesseract-ios-lib │ ├── include │ │ ├── tesseract │ │ │ ├── hosthplb.h │ │ │ ├── hpdsizes.h │ │ │ ├── secname.h │ │ │ ├── stderr.h │ │ │ ├── ndminx.h │ │ │ ├── tessvars.h │ │ │ ├── genblob.h │ │ │ ├── tessbox.h │ │ │ ├── tessedit.h │ │ │ ├── hashfn.h │ │ │ ├── notdll.h │ │ │ ├── docqual.h │ │ │ ├── werdit.h │ │ │ ├── imgscale.h │ │ │ ├── blckerr.h │ │ │ ├── basedir.h │ │ │ ├── fixspace.h │ │ │ ├── tfacep.h │ │ │ ├── apitypes.h │ │ │ ├── crakedge.h │ │ │ ├── mfcpch.h │ │ │ ├── output.h │ │ │ ├── blread.h │ │ │ ├── tprintf.h │ │ │ ├── fileerr.h │ │ │ ├── globaloc.h │ │ │ ├── reject.h │ │ │ ├── hpddef.h │ │ │ ├── scaleimg.h │ │ │ ├── unicodes.h │ │ │ ├── control.h │ │ │ ├── serialis.h │ │ │ ├── memry.h │ │ │ ├── ccstruct.h │ │ │ ├── tesseractmain.h │ │ │ ├── polyaprx.h │ │ │ ├── lsterr.h │ │ │ ├── tfacepp.h │ │ │ ├── bits16.h │ │ │ ├── platform.h │ │ │ ├── quadratc.h │ │ │ ├── quadlsq.h │ │ │ ├── scanutils.h │ │ │ ├── boxread.h │ │ │ ├── otsuthr.h │ │ │ ├── mutableiterator.h │ │ │ ├── vecfuncs.h │ │ │ ├── mod128.h │ │ │ ├── cubeclassifier.h │ │ │ ├── stepblob.h │ │ │ ├── ccutil.h │ │ │ ├── unicharmap.h │ │ │ ├── qrsequence.h │ │ │ ├── linlsq.h │ │ │ ├── split.h │ │ │ ├── unichar.h │ │ │ ├── quspline.h │ │ │ ├── pgedit.h │ │ │ ├── errcode.h │ │ │ ├── polyblk.h │ │ │ ├── detlinefit.h │ │ │ ├── bitvector.h │ │ │ ├── dppoint.h │ │ │ ├── sorthelper.h │ │ │ ├── tesseract_cube_combiner.h │ │ │ └── boxword.h │ │ └── leptonica │ │ │ ├── endianness.h │ │ │ ├── freetype.h │ │ │ ├── leptwin.h │ │ │ ├── alltypes.h │ │ │ ├── bbuffer.h │ │ │ ├── bmf.h │ │ │ ├── stack.h │ │ │ ├── sudoku.h │ │ │ ├── queue.h │ │ │ ├── watershed.h │ │ │ ├── list.h │ │ │ ├── gplot.h │ │ │ ├── ptra.h │ │ │ ├── bmp.h │ │ │ └── heap.h │ ├── lib │ │ ├── liblept.a │ │ └── libtesseract_all.a │ └── README.md └── Tesseract-Wrapper │ └── Tesseract.h ├── OCR-Example ├── en.lproj │ └── InfoPlist.strings ├── Default.png ├── Default@2x.png ├── Default-568h@2x.png ├── AppDelegate.h ├── OCR-Example-Prefix.pch ├── main.m ├── PhotoChooserViewController.h ├── ResultsViewController.h ├── OCR-Example-Info.plist ├── AppDelegate.m ├── ResultsViewController.mm ├── PhotoChooserViewController.m └── ImageProcessing.h ├── images └── ocr-ios-screenshot01.png ├── .gitignore └── README.md /External/tesseract-ios-lib/include/tesseract/hosthplb.h: -------------------------------------------------------------------------------- 1 | #include "host.h" 2 | -------------------------------------------------------------------------------- /OCR-Example/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /OCR-Example/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cconstable/OCR-iOS-Example/HEAD/OCR-Example/Default.png -------------------------------------------------------------------------------- /OCR-Example/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cconstable/OCR-iOS-Example/HEAD/OCR-Example/Default@2x.png -------------------------------------------------------------------------------- /OCR-Example/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cconstable/OCR-iOS-Example/HEAD/OCR-Example/Default-568h@2x.png -------------------------------------------------------------------------------- /images/ocr-ios-screenshot01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cconstable/OCR-iOS-Example/HEAD/images/ocr-ios-screenshot01.png -------------------------------------------------------------------------------- /External/tesseract-ios-lib/lib/liblept.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cconstable/OCR-iOS-Example/HEAD/External/tesseract-ios-lib/lib/liblept.a -------------------------------------------------------------------------------- /External/tesseract-ios-lib/lib/libtesseract_all.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cconstable/OCR-iOS-Example/HEAD/External/tesseract-ios-lib/lib/libtesseract_all.a -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/hpdsizes.h: -------------------------------------------------------------------------------- 1 | #ifndef HPDSIZES_H 2 | #define HPDSIZES_H 3 | 4 | #define NUM_TEXT_ATTR 10 5 | #define NUM_BLOCK_ATTR 7 6 | #define MAXLENGTH 128 7 | #define NUM_BACKGROUNDS 8 8 | #endif 9 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/endianness.h: -------------------------------------------------------------------------------- 1 | #if !defined (L_BIG_ENDIAN) && !defined (L_LITTLE_ENDIAN) 2 | # if 0 3 | # ifdef __BIG_ENDIAN__ 4 | # define L_BIG_ENDIAN 5 | # else 6 | # define L_LITTLE_ENDIAN 7 | # endif 8 | # else 9 | # define L_LITTLE_ENDIAN 10 | # endif 11 | #endif 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | -------------------------------------------------------------------------------- /OCR-Example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OCR-Example 4 | // 5 | // Created by Christopher Constable on 5/10/13. 6 | // Copyright (c) 2013 Christopher Constable. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/secname.h: -------------------------------------------------------------------------------- 1 | /* Include this file in any module which needs to have conditional compilation 2 | of sensitive code for UNLV. In INTERNAL mode SECURE_NAMES is NOT defined. 3 | For UNLV mode it IS defined, allowing multiple modules to do conditional 4 | compilation on the same name. 5 | */ 6 | 7 | #ifndef SECURE_NAMES 8 | /* #define SECURE_NAMES */ 9 | #endif 10 | -------------------------------------------------------------------------------- /OCR-Example/OCR-Example-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'OCR-Example' target in the 'OCR-Example' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_5_0 8 | #warning "This project uses features only available in iOS SDK 5.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /OCR-Example/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OCR-Example 4 | // 5 | // Created by Christopher Constable on 5/10/13. 6 | // Copyright (c) 2013 Christopher Constable. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OCR-Example/PhotoChooserViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // OCR-Example 4 | // 5 | // Created by Christopher Constable on 5/10/13. 6 | // Copyright (c) 2013 Christopher Constable. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PhotoChooserViewController : UIViewController 12 | 13 | @property (weak, nonatomic) IBOutlet UIImageView *selectedImageView; 14 | - (IBAction)choosePhotoWasTapped:(id)sender; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /OCR-Example/ResultsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ResultsViewController.h 3 | // OCR-Example 4 | // 5 | // Created by Christopher Constable on 5/10/13. 6 | // Copyright (c) 2013 Christopher Constable. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ResultsViewController : UIViewController 12 | 13 | @property (nonatomic, strong) UIView *loadingView; 14 | 15 | @property (weak, nonatomic) UIImage *selectedImage; 16 | @property (weak, nonatomic) IBOutlet UIImageView *selectedImageView; 17 | @property (weak, nonatomic) IBOutlet UITextView *resultsTextView; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /External/Tesseract-Wrapper/Tesseract.h: -------------------------------------------------------------------------------- 1 | // 2 | // Tesseract.h 3 | // Tesseract 4 | // 5 | // Created by Loïs Di Qual on 24/09/12. 6 | // Copyright (c) 2012 Loïs Di Qual. 7 | // Under MIT License. See 'LICENCE' for more informations. 8 | // 9 | 10 | #import 11 | 12 | @interface Tesseract : NSObject { 13 | NSString* _dataPath; 14 | NSString* _language; 15 | NSMutableDictionary* _variables; 16 | } 17 | 18 | + (NSString *)version; 19 | 20 | - (id)initWithDataPath:(NSString *)dataPath language:(NSString *)language; 21 | - (void)setVariableValue:(NSString *)value forKey:(NSString *)key; 22 | - (void)setImage:(UIImage *)image; 23 | - (BOOL)setLanguage:(NSString *)language; 24 | - (BOOL)recognize; 25 | - (NSString *)recognizedText; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/README.md: -------------------------------------------------------------------------------- 1 | Tesseract Lib for iOS 2 | ===================== 3 | 4 | 5 | About 6 | ----- 7 | 8 | This project contains only the [leptonica](http://www.leptonica.com/download.html) and [tesseract-ocr](http://code.google.com/p/tesseract-ocr/) libraries compiled for iOS. 9 | 10 | There is no support for armv6, so it won't work with iPhone 1st Gen and iPhone 3G. 11 | 12 | 13 | Usage 14 | ----- 15 | 16 | You might want to use this [tesseract-ios](https://github.com/ldiqual/tesseract-ios) to include Tesseract in your iOS project. For a more advanced usage, you can use the raw library with regular C++ code. 17 | 18 | Don't forget to rename your implementation classes with `.mm` instead of `.m` as it uses C++ code. 19 | 20 | 21 | Code Sample 22 | ----------- 23 | 24 | Follow [this blog post](http://tinsuke.wordpress.com/2011/11/01/how-to-compile-and-use-tesseract-3-01-on-ios-sdk-5/) for more informations. 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/stderr.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: stderr.h (Formerly stderrs.h) 3 | * Description: File defining error messages fundamental of commonly used. 4 | * Author: Ray Smith 5 | * Created: Fri Aug 10 15:23:14 BST 1990 6 | * 7 | * (C) Copyright 1990, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef STDERR_H 21 | #define STDERR_H 22 | 23 | #include "errcode.h" 24 | 25 | const ERRCODE MEMORY_OUT = "Out of memory"; 26 | #endif 27 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/freetype.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2008 Leptonica. All rights reserved. 3 | - This software is distributed in the hope that it will be 4 | - useful, but with NO WARRANTY OF ANY KIND. 5 | - No author or distributor accepts responsibility to anyone for the 6 | - consequences of using this software, or for whether it serves any 7 | - particular purpose or works at all, unless he or she says so in 8 | - writing. Everyone is granted permission to copy, modify and 9 | - redistribute this source code, for commercial or non-commercial 10 | - purposes, with the following restrictions: (1) the origin of this 11 | - source code must not be misrepresented; (2) modified versions must 12 | - be plainly marked as such; and (3) this notice may not be removed 13 | - or altered from any source or modified source distribution. 14 | *====================================================================*/ 15 | 16 | #ifndef LEPTONICA_FREETYPE_H 17 | #define LEPTONICA_FREETYPE_H 18 | 19 | #define LEPTONICA_FT_RESOLUTION 96 20 | 21 | typedef struct ft_library_st FT_LIBRARY; 22 | 23 | #endif /* LEPTONICA_FREETYPE_H */ 24 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/ndminx.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: ndminx.h (Formerly ndminmax.h) 3 | * Description: Extended ascii chars 4 | * Author: Phil Cheatle 5 | * Created: Mon Mar 29 14:46:01 BST 1993 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef NDMINX_H 21 | #define NDMINX_H 22 | 23 | #ifndef MAX 24 | #define MAX(x,y) (((x) >= (y))?(x):(y)) 25 | #endif 26 | 27 | #ifndef MIN 28 | #define MIN(x,y) (((x) <= (y))?(x):(y)) 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/tessvars.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: tessvars.h (Formerly tessvars.h) 3 | * Description: Variables and other globals for tessedit. 4 | * Author: Ray Smith 5 | * Created: Mon Apr 13 13:13:23 BST 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TESSVARS_H 21 | #define TESSVARS_H 22 | 23 | #include 24 | 25 | #include "img.h" 26 | #include "notdll.h" 27 | 28 | extern FILE *debug_fp; // write debug stuff here 29 | #endif 30 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/genblob.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: genblob.h (Formerly gblob.h) 3 | * Description: Generic Blob processing routines 4 | * Author: Phil Cheatle 5 | * Created: Mon Nov 25 10:53:26 GMT 1991 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef GENBLOB_H 21 | #define GENBLOB_H 22 | 23 | // Sort function to sort blobs by ascending left edge. 24 | int c_blob_comparator(const void *blob1p, // ptr to ptr to blob1 25 | const void *blob2p); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/tessbox.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: tessbox.h (Formerly tessbox.h) 3 | * Description: Black boxed Tess for developing a resaljet. 4 | * Author: Ray Smith 5 | * Created: Thu Apr 23 11:03:36 BST 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TESSBOX_H 21 | #define TESSBOX_H 22 | 23 | #include "ratngs.h" 24 | #include "notdll.h" 25 | #include "tesseractclass.h" 26 | 27 | // TODO(ocr-team): Delete this along with other empty header files. 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/tessedit.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: tessedit.h (Formerly tessedit.h) 3 | * Description: Main program for merge of tess and editor. 4 | * Author: Ray Smith 5 | * Created: Tue Jan 07 15:21:46 GMT 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TESSEDIT_H 21 | #define TESSEDIT_H 22 | 23 | #include "blobs.h" 24 | #include "pgedit.h" 25 | #include "notdll.h" 26 | 27 | //progress monitor 28 | extern ETEXT_DESC *global_monitor; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/hashfn.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: hashfn.h (Formerly hash.h) 3 | * Description: Simple hash function. 4 | * Author: Ray Smith 5 | * Created: Thu Jan 16 11:47:59 GMT 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef HASHFN_H 21 | #define HASHFN_H 22 | 23 | #include "host.h" 24 | 25 | inT32 hash( //hash function 26 | inT32 bits, //bits in hash function 27 | void *key, //key to hash 28 | inT32 keysize //size of key 29 | ); 30 | #endif 31 | -------------------------------------------------------------------------------- /OCR-Example/OCR-Example-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | Christopher-Constable.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | MainStoryboard 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationPortraitUpsideDown 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/notdll.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: notdll.h 3 | * Description: Defines for dll symbols for any program using a dll. 4 | * Author: Ray Smith 5 | * Created: Tue Apr 30 16:15:01 MDT 1996 6 | * 7 | * (C) Copyright 1996, Hewlett-Packard Co. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | //This file does NOT use the usual single inclusion code as it 21 | //is necessary to allow it to be executed every time it is included. 22 | //#ifndef NOTDLL_H 23 | //#define NOTDLL_H 24 | 25 | #undef DLLSYM 26 | #define DLLSYM 27 | 28 | //#endif 29 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/docqual.h: -------------------------------------------------------------------------------- 1 | /****************************************************************** 2 | * File: docqual.h (Formerly docqual.h) 3 | * Description: Document Quality Metrics 4 | * Author: Phil Cheatle 5 | * Created: Mon May 9 11:27:28 BST 1994 6 | * 7 | * (C) Copyright 1994, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef DOCQUAL_H 21 | #define DOCQUAL_H 22 | 23 | #include "control.h" 24 | #include "notdll.h" 25 | 26 | enum GARBAGE_LEVEL 27 | { 28 | G_NEVER_CRUNCH, 29 | G_OK, 30 | G_DODGY, 31 | G_TERRIBLE 32 | }; 33 | 34 | inT16 word_blob_quality(WERD_RES *word, ROW *row); 35 | void reject_whole_page(PAGE_RES_IT &page_res_it); 36 | #endif 37 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/werdit.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: wordit.c 3 | * Description: An iterator for passing over all the words in a document. 4 | * Author: Ray Smith 5 | * Created: Mon Apr 27 08:51:22 BST 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef WERDIT_H 21 | #define WERDIT_H 22 | 23 | #include "pageres.h" 24 | #include "notdll.h" 25 | 26 | WERD *make_pseudo_word(PAGE_RES* page_res, // blocks to check 27 | TBOX &selection_box, 28 | BLOCK *&pseudo_block, 29 | ROW *&pseudo_row); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/imgscale.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: imgscale.h (Formerly dyn_prog.h) 3 | * Description: Dynamic programming for smart scaling of images. 4 | * Author: Phil Cheatle 5 | * Created: Wed Nov 18 16:12:03 GMT 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef IMGSCALE_H 21 | #define IMGSCALE_H 22 | 23 | void dyn_prog( //The clever bit 24 | int n, 25 | int *x, 26 | int *y, 27 | int ymax, 28 | int *oldx, 29 | int *oldy, 30 | int oldn, 31 | float factor); 32 | #endif 33 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/blckerr.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: blckerr.h (Formerly blockerr.h) 3 | * Description: Error codes for the page block classes. 4 | * Author: Ray Smith 5 | * Created: Tue Mar 19 17:43:30 GMT 1991 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef BLCKERR_H 21 | #define BLCKERR_H 22 | 23 | #include "errcode.h" 24 | 25 | const ERRCODE BADBLOCKLINE = "Y coordinate in block out of bounds"; 26 | const ERRCODE LOSTBLOCKLINE = "Can't find rectangle for line"; 27 | const ERRCODE ILLEGAL_GRADIENT = "Gradient wrong side of edge step!"; 28 | const ERRCODE WRONG_WORD = "Word doesn't have blobs of that type"; 29 | #endif 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OCR-iOS-Example 2 | =============== 3 | 4 | A simple example of how to do optical character recognition (OCR) on iOS. 5 | 6 | ### About 7 | 8 | This was a little project I did one night to see how well OCR performed on the iPhone using Tesseract (an OCR library). Luckily for me, some people have already done the heavy lifting (compliled the libraries for iOS, made wrappers, etc). Here, I've simply brought that all together in project that should have you going with minimal setup. 9 | 10 | ### Setup 11 | 12 | 1. Clone this repo. 13 | 2. Go to [https://code.google.com/p/tesseract-ocr/downloads/list](https://code.google.com/p/tesseract-ocr/downloads/list) to download a language dataset. 14 | 3. Place your decompressed tesseract data in a folder called `tessdata` like this: 15 | 16 | ![image](https://raw.github.com/mstrchrstphr/OCR-iOS-Example/master/images/ocr-ios-screenshot01.png) 17 | 18 | 19 | That's it! The source code shouldn't be too difficult to follow. Feel free to do whatever you like with this. 20 | 21 | ### Brought to you by 22 | 23 | [https://code.google.com/p/tesseract-ocr](https://code.google.com/p/tesseract-ocr) 24 |
25 | [https://github.com/ldiqual/tesseract-ios](https://github.com/ldiqual/tesseract-ios) 26 |
27 | [http://tinsuke.wordpress.com/2011/11/01/how-to-compile-and-use-tesseract-3-01-on-ios-sdk-5](http://tinsuke.wordpress.com/2011/11/01/how-to-compile-and-use-tesseract-3-01-on-ios-sdk-5) 28 | 29 | 30 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/basedir.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: basedir.h (Formerly getpath.h) 3 | * Description: Header file for getpath.c. Provides relocatability of data. 4 | * Author: Ray Smith 5 | * Created: Mon Jul 09 09:13:03 BST 1990 6 | * 7 | * (C) Copyright 1990, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef BASEDIR_H 21 | #define BASEDIR_H 22 | 23 | #include "platform.h" 24 | #include "strngs.h" 25 | 26 | // Returns the given code_path truncated to the last slash. 27 | // Useful for getting to the directory of argv[0], but does not search 28 | // any paths. 29 | TESS_API void truncate_path(const char *code_path, STRING* trunc_path); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/fixspace.h: -------------------------------------------------------------------------------- 1 | /****************************************************************** 2 | * File: fixspace.h (Formerly fixspace.h) 3 | * Description: Implements a pass over the page res, exploring the alternative 4 | * spacing possibilities, trying to use context to improve the 5 | word spacing 6 | * Author: Phil Cheatle 7 | * Created: Thu Oct 21 11:38:43 BST 1993 8 | * 9 | * (C) Copyright 1993, Hewlett-Packard Ltd. 10 | ** Licensed under the Apache License, Version 2.0 (the "License"); 11 | ** you may not use this file except in compliance with the License. 12 | ** You may obtain a copy of the License at 13 | ** http://www.apache.org/licenses/LICENSE-2.0 14 | ** Unless required by applicable law or agreed to in writing, software 15 | ** distributed under the License is distributed on an "AS IS" BASIS, 16 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | ** See the License for the specific language governing permissions and 18 | ** limitations under the License. 19 | * 20 | **********************************************************************/ 21 | 22 | #ifndef FIXSPACE_H 23 | #define FIXSPACE_H 24 | 25 | #include "pageres.h" 26 | #include "params.h" 27 | #include "notdll.h" 28 | 29 | void initialise_search(WERD_RES_LIST &src_list, WERD_RES_LIST &new_list); 30 | void transform_to_next_perm(WERD_RES_LIST &words); 31 | void fixspace_dbg(WERD_RES *word); 32 | #endif 33 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/tfacep.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: tfacep.h (Formerly tfacep.h) 3 | * Description: Declarations of C functions and C owned data. 4 | * Author: Ray Smith 5 | * Created: Mon Apr 27 12:51:28 BST 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TFACEP_H 21 | #define TFACEP_H 22 | 23 | #include "hosthplb.h" 24 | #include "blobs.h" 25 | #include "tessarray.h" 26 | #include "notdll.h" 27 | #include "oldlist.h" 28 | #include "permute.h" 29 | #include "blobclass.h" 30 | #include "stopper.h" 31 | #include "associate.h" 32 | #include "chop.h" 33 | #include "structures.h" 34 | 35 | typedef void (*TESS_TESTER) (TBLOB *, BOOL8, char *, inT32, LIST); 36 | typedef LIST (*TESS_MATCHER) (TBLOB *, TBLOB *, TBLOB *); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/apitypes.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: apitypes.h 3 | // Description: Types used in both the API and internally 4 | // Author: Ray Smith 5 | // Created: Wed Mar 03 09:22:53 PST 2010 6 | // 7 | // (C) Copyright 2010, Google Inc. 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | /////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef TESSERACT_API_APITYPES_H__ 21 | #define TESSERACT_API_APITYPES_H__ 22 | 23 | #include "publictypes.h" 24 | 25 | // The types used by the API and Page/ResultIterator can be found in: 26 | // ccstruct/publictypes.h 27 | // ccmain/resultiterator.h 28 | // ccmain/pageiterator.h 29 | // API interfaces and API users should be sure to include this file, rather 30 | // than the lower-level one, and lower-level code should be sure to include 31 | // only the lower-level file. 32 | 33 | #endif // TESSERACT_API_APITYPES_H__ 34 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/crakedge.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: crakedge.h (Formerly: crkedge.h) 3 | * Description: Sturctures for the Crack following edge detector. 4 | * Author: Ray Smith 5 | * Created: Fri Mar 22 16:06:38 GMT 1991 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef CRAKEDGE_H 21 | #define CRAKEDGE_H 22 | 23 | #include "points.h" 24 | #include "mod128.h" 25 | 26 | class CRACKEDGE { 27 | public: 28 | CRACKEDGE() {} 29 | 30 | ICOORD pos; /*position of crack */ 31 | inT8 stepx; //edge step 32 | inT8 stepy; 33 | inT8 stepdir; //chaincode 34 | CRACKEDGE *prev; /*previous point */ 35 | CRACKEDGE *next; /*next point */ 36 | }; 37 | #endif 38 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/mfcpch.h: -------------------------------------------------------------------------------- 1 | // mfcpch.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | // For Unix and mac the file does nothing. It needs to be included in all cpp 6 | // files for compatibility with the PC pre-compiled header mechanism. 7 | #ifdef _WIN32 8 | #ifndef _AFXDLL 9 | #define WIN32_LEAN_AND_MEAN 10 | #define STRICT 1 11 | //#include 12 | #include 13 | #else 14 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 15 | 16 | #include // mfc core and standard components 17 | #include // mfc extensions 18 | 19 | #ifndef _AFX_NO_OLE_SUPPORT 20 | #include // mfc ole classes 21 | #include // mfc ole dialog classes 22 | #include // mfc ole automation classes 23 | #endif // _AFX_NO_OLE_SUPPORT 24 | 25 | #ifndef _AFX_NO_DB_SUPPORT 26 | #include // mfc odbc database classes 27 | #endif // _AFX_NO_DB_SUPPORT 28 | 29 | #ifndef _AFX_NO_DAO_SUPPORT 30 | #include // mfc dao database classes 31 | #endif // _AFX_NO_DAO_SUPPORT 32 | 33 | #ifndef _AFX_NO_AFXCMN_SUPPORT 34 | #include // mfc support for windows 95 common controls 35 | #endif // _AFX_NO_AFXCMN_SUPPORT 36 | #endif 37 | #endif 38 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/output.h: -------------------------------------------------------------------------------- 1 | /****************************************************************** 2 | * File: output.h (Formerly output.h) 3 | * Description: Output pass 4 | * Author: Phil Cheatle 5 | * Created: Thu Aug 4 10:56:08 BST 1994 6 | * 7 | * (C) Copyright 1994, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef OUTPUT_H 21 | #define OUTPUT_H 22 | 23 | #include "params.h" 24 | //#include "epapconv.h" 25 | #include "pageres.h" 26 | #include "notdll.h" 27 | 28 | /** test line ends */ 29 | char determine_newline_type(WERD *word, ///< word to do 30 | BLOCK *block, ///< current block 31 | WERD *next_word, ///< next word 32 | BLOCK *next_block ///< block of next word 33 | ); 34 | #endif 35 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/blread.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: blread.h (Formerly pdread.h) 3 | * Description: Friend function of BLOCK to read the uscan pd file. 4 | * Author: Ray Smith 5 | * Created: Mon Mar 18 14:39:00 GMT 1991 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef BLREAD_H 21 | #define BLREAD_H 22 | 23 | #include "params.h" 24 | #include "ocrblock.h" 25 | 26 | bool read_unlv_file( //print list of sides 27 | STRING name, //basename of file 28 | inT32 xsize, //image size 29 | inT32 ysize, //image size 30 | BLOCK_LIST *blocks //output list 31 | ); 32 | void FullPageBlock(int width, int height, BLOCK_LIST *blocks); 33 | #endif 34 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/tprintf.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: tprintf.c 3 | * Description: Trace version of printf - portable between UX and NT 4 | * Author: Phil Cheatle 5 | * Created: Wed Jun 28 15:01:15 BST 1995 6 | * 7 | * (C) Copyright 1995, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TPRINTF_H 21 | #define TPRINTF_H 22 | 23 | #include "params.h" 24 | 25 | extern DLLSYM STRING_VAR_H (debug_file, "", "File to send tprintf output to"); 26 | extern DLLSYM BOOL_VAR_H (debug_window_on, TRUE, 27 | "Send tprintf to window unless file set"); 28 | 29 | extern TESS_API void tprintf( // Trace printf 30 | const char *format, ... // special message 31 | ); 32 | // special message 33 | DLLSYM BOOL8 pause_continue (const char *format, ... 34 | ); 35 | #endif 36 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/fileerr.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: fileerr.h (Formerly filerr.h) 3 | * Description: Errors for file utilities. 4 | * Author: Ray Smith 5 | * Created: Tue Aug 14 15:45:16 BST 1990 6 | * 7 | * (C) Copyright 1990, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef FILEERR_H 21 | #define FILEERR_H 22 | 23 | #include "errcode.h" 24 | 25 | const ERRCODE CANTOPENFILE = "Can't open file"; 26 | const ERRCODE CANTCREATEFILE = "Can't create file"; 27 | const ERRCODE CANTMAKEPIPE = "Can't create pipe"; 28 | const ERRCODE CANTCONNECTPIPE = "Can't reconnect pipes to stdin/stdout"; 29 | const ERRCODE READFAILED = "Read of file failed"; 30 | const ERRCODE WRITEFAILED = "Write of file failed"; 31 | const ERRCODE SELECTFAILED = "Select failed"; 32 | 33 | const ERRCODE EXECFAILED = "Could not exec new process"; 34 | #endif 35 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/globaloc.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: errcode.h (Formerly error.h) 3 | * Description: Header file for generic error handler class 4 | * Author: Ray Smith 5 | * Created: Tue May 1 16:23:36 BST 1990 6 | * 7 | * (C) Copyright 1990, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef GLOBALOC_H 21 | #define GLOBALOC_H 22 | 23 | #include "hosthplb.h" 24 | #include "notdll.h" 25 | 26 | void signal_exit( // 27 | int signal_code //Signal which 28 | ); 29 | //extern "C" { 30 | void err_exit(); 31 | //The real signal 32 | void signal_termination_handler(int sig); 33 | //}; 34 | 35 | void set_global_loc_code(int loc_code); 36 | 37 | void set_global_subloc_code(int loc_code); 38 | 39 | void set_global_subsubloc_code(int loc_code); 40 | #endif 41 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/reject.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: reject.h (Formerly reject.h) 3 | * Description: Rejection functions used in tessedit 4 | * Author: Phil Cheatle 5 | * Created: Wed Sep 23 16:50:21 BST 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef REJECT_H 21 | #define REJECT_H 22 | 23 | #include "params.h" 24 | #include "pageres.h" 25 | #include "notdll.h" 26 | 27 | void reject_blanks(WERD_RES *word); 28 | void reject_poor_matches(WERD_RES *word, BLOB_CHOICE_LIST_CLIST *blob_choices); 29 | float compute_reject_threshold(BLOB_CHOICE_LIST_CLIST *blob_choices); 30 | BOOL8 word_contains_non_1_digit(const char *word, const char *word_lengths); 31 | void dont_allow_1Il(WERD_RES *word); 32 | void flip_hyphens(WERD_RES *word); 33 | void flip_0O(WERD_RES *word); 34 | BOOL8 non_0_digit(const char* str, int length); 35 | #endif 36 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/hpddef.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: hpddef.h 3 | * Description: Defines for dll symbols for handpd.dll. 4 | * Author: Ray Smith 5 | * Created: Tue Apr 30 17:15:01 MDT 1996 6 | * 7 | * (C) Copyright 1996, Hewlett-Packard Co. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | //This file does NOT use the usual single inclusion code as it 21 | //is necessary to allow it to be executed every time it is included. 22 | //#ifndef HPDDEF_H 23 | //#define HPDDEF_H 24 | 25 | #undef DLLSYM 26 | #ifndef __IPEDLL 27 | # define DLLSYM 28 | #else 29 | # ifdef __BUILDING_HANDPD__ 30 | # define DLLSYM DLLEXPORT 31 | # else 32 | # define DLLSYM DLLIMPORT 33 | # endif 34 | #endif 35 | #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__) 36 | # pragma import on 37 | #endif 38 | 39 | //#endif 40 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/scaleimg.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: scaleimg.h (Formerly scaleim.h) 3 | * Description: Smart scaling of images. 4 | * Author: Phil Cheatle 5 | * Created: Wed Nov 18 16:12:03 GMT 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef SCALEIMG_H 21 | #define SCALEIMG_H 22 | 23 | void scale_image( //scale an image 24 | IMAGE &image, //source image 25 | IMAGE &target_image //target image 26 | ); 27 | void scale_image_cop_out( //scale an image 28 | IMAGE &image, //source image 29 | IMAGE &target_image, //target image 30 | float factor, //scale factor 31 | int *hires, 32 | int *lores, 33 | int *oldhires, 34 | int *oldlores); 35 | #endif 36 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/unicodes.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: unicodes.h 3 | * Description: Unicode related machinery 4 | * Author: David Eger 5 | * Created: Wed Jun 15 16:37:50 PST 2011 6 | * 7 | * (C) Copyright 2011, Google, Inc. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TESSERACT_CCUTIL_UNICODES_H__ 21 | #define TESSERACT_CCUTIL_UNICODES_H__ 22 | 23 | namespace tesseract { 24 | 25 | extern const char *kUTF8LineSeparator; 26 | extern const char *kUTF8ParagraphSeparator; 27 | extern const char *kLRM; // Left-to-Right Mark 28 | extern const char *kRLM; // Right-to-Left Mark 29 | extern const char *kRLE; // Right-to-Left Embedding 30 | extern const char *kPDF; // Pop Directional Formatting 31 | 32 | // The following are confusable internal word punctuation symbols 33 | // which we normalize to the first variant when matching in dawgs. 34 | extern const char *kHyphenLikeUTF8[]; 35 | extern const char *kApostropheLikeUTF8[]; 36 | 37 | } // namespace 38 | 39 | #endif // TESSERACT_CCUTIL_UNICODES_H__ 40 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/control.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: control.h (Formerly control.h) 3 | * Description: Module-independent matcher controller. 4 | * Author: Ray Smith 5 | * Created: Thu Apr 23 11:09:58 BST 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | /** 21 | * @file control.h 22 | * Module-independent matcher controller. 23 | */ 24 | 25 | #ifndef CONTROL_H 26 | #define CONTROL_H 27 | 28 | #include "params.h" 29 | #include "ocrblock.h" 30 | #include "ratngs.h" 31 | #include "statistc.h" 32 | #include "pageres.h" 33 | #include "notdll.h" 34 | 35 | enum ACCEPTABLE_WERD_TYPE 36 | { 37 | AC_UNACCEPTABLE, ///< Unacceptable word 38 | AC_LOWER_CASE, ///< ALL lower case 39 | AC_UPPER_CASE, ///< ALL upper case 40 | AC_INITIAL_CAP, ///< ALL but initial lc 41 | AC_LC_ABBREV, ///< a.b.c. 42 | AC_UC_ABBREV ///< A.B.C. 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/serialis.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: serialis.h (Formerly serialmac.h) 3 | * Description: Inline routines and macros for serialisation functions 4 | * Author: Phil Cheatle 5 | * Created: Tue Oct 08 08:33:12 BST 1991 6 | * 7 | * (C) Copyright 1990, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef SERIALIS_H 21 | #define SERIALIS_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include "memry.h" 27 | #include "errcode.h" 28 | #include "fileerr.h" 29 | 30 | // Switch endinan. 31 | extern DLLSYM uinT64 reverse64(uinT64); 32 | extern DLLSYM uinT32 reverse32(uinT32); 33 | extern DLLSYM uinT16 reverse16(uinT16); 34 | 35 | /*********************************************************************** 36 | QUOTE_IT MACRO DEFINITION 37 | =========================== 38 | Replace with "". may be an arbitrary number of tokens 39 | ***********************************************************************/ 40 | 41 | #define QUOTE_IT( parm ) #parm 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/memry.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: memry.h (Formerly memory.h) 3 | * Description: Header file for basic memory allocation/deallocation. 4 | * Author: Ray Smith 5 | * Created: Tue May 8 16:03:48 BST 1990 6 | * 7 | * (C) Copyright 1990, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef MEMRY_H 21 | #define MEMRY_H 22 | 23 | #include 24 | #include "host.h" 25 | 26 | // allocate string 27 | extern char *alloc_string(inT32 count); 28 | // free a string. 29 | extern void free_string(char *string); 30 | // allocate memory 31 | extern void *alloc_struct(inT32 count, const char *name = NULL); 32 | // free a structure. 33 | extern void free_struct(void *deadstruct, inT32, const char *name = NULL); 34 | // get some memory 35 | extern void *alloc_mem(inT32 count); 36 | // get some memory initialized to 0. 37 | extern void *alloc_big_zeros(inT32 count); 38 | // free mem from alloc_mem 39 | extern void free_mem(void *oldchunk); 40 | // free mem from alloc_big_zeros 41 | extern void free_big_mem(void *oldchunk); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/ccstruct.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: ccstruct.h 3 | // Description: ccstruct class. 4 | // Author: Samuel Charron 5 | // 6 | // (C) Copyright 2006, Google Inc. 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | /////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef TESSERACT_CCSTRUCT_CCSTRUCT_H__ 20 | #define TESSERACT_CCSTRUCT_CCSTRUCT_H__ 21 | 22 | #include "cutil.h" 23 | #include "image.h" 24 | 25 | namespace tesseract { 26 | class CCStruct : public CUtil { 27 | public: 28 | CCStruct(); 29 | ~CCStruct(); 30 | 31 | // Globally accessible constants. 32 | // APPROXIMATIONS of the fractions of the character cell taken by 33 | // the descenders, ascenders, and x-height. 34 | static const double kDescenderFraction; // = 0.25; 35 | static const double kXHeightFraction; // = 0.5; 36 | static const double kAscenderFraction; // = 0.25; 37 | // Derived value giving the x-height as a fraction of cap-height. 38 | static const double kXHeightCapRatio; // = XHeight/(XHeight + Ascender). 39 | 40 | protected: 41 | Image image_; 42 | }; 43 | 44 | class Tesseract; 45 | } // namespace tesseract 46 | 47 | 48 | #endif // TESSERACT_CCSTRUCT_CCSTRUCT_H__ 49 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/tesseractmain.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: tessedit.h (Formerly tessedit.h) 3 | * Description: Main program for merge of tess and editor. 4 | * Author: Ray Smith 5 | * Created: Tue Jan 07 15:21:46 GMT 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TESSERACTMAIN_H 21 | #define TESSERACTMAIN_H 22 | 23 | #ifdef _WIN32 24 | /** 25 | * main for windows command line 26 | */ 27 | int WINAPI WinMain(HINSTANCE hInstance, 28 | HINSTANCE hPrevInstance, 29 | LPSTR lpszCmdLine, 30 | int nCmdShow); 31 | /** 32 | * message handler 33 | * @param hwnd window with message 34 | * @param msg message type 35 | */ 36 | LONG WINAPI WndProc(HWND hwnd, 37 | UINT msg, 38 | WPARAM wParam, 39 | LPARAM lParam); 40 | /** 41 | * refine argument list 42 | * @param argc number of input arguments 43 | * @param argv input arguments 44 | * @param arglist output arguments 45 | */ 46 | int parse_args (int argc, 47 | char *argv[], 48 | char *arglist[]); 49 | #endif 50 | #endif 51 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/polyaprx.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: polyaprx.h (Formerly polygon.h) 3 | * Description: Code for polygonal approximation from old edgeprog. 4 | * Author: Ray Smith 5 | * Created: Thu Nov 25 11:42:04 GMT 1993 6 | * 7 | * (C) Copyright 1993, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef POLYAPRX_H 21 | #define POLYAPRX_H 22 | 23 | #include "blobs.h" 24 | #include "coutln.h" 25 | 26 | // convert a chain-coded input to the old OUTLINE approximation 27 | TESSLINE* ApproximateOutline(C_OUTLINE *c_outline); 28 | EDGEPT *edgesteps_to_edgepts ( //convert outline 29 | C_OUTLINE * c_outline, //input 30 | EDGEPT edgepts[] //output is array 31 | ); 32 | void fix2( //polygonal approx 33 | EDGEPT *start, /*loop to approimate */ 34 | int area); 35 | EDGEPT *poly2( //second poly 36 | EDGEPT *startpt, /*start of loop */ 37 | int area /*area of blob box */ 38 | ); 39 | void cutline( //recursive refine 40 | EDGEPT *first, /*ends of line */ 41 | EDGEPT *last, 42 | int area /*area of object */ 43 | ); 44 | #endif 45 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/lsterr.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: lsterr.h (Formerly listerr.h) 3 | * Description: Errors shared by list modules 4 | * Author: Phil Cheatle 5 | * Created: Wed Jan 23 09:10:35 GMT 1991 6 | * 7 | * (C) Copyright 1990, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #include "errcode.h" //must be last include 21 | 22 | #ifndef LSTERR_H 23 | #define LSTERR_H 24 | 25 | const ERRCODE DONT_CONSTRUCT_LIST_BY_COPY = 26 | "Can't create a list by assignment"; 27 | const ERRCODE DONT_ASSIGN_LISTS = "Can't assign to lists"; 28 | const ERRCODE SERIALISE_LINKS = "Attempted to (de)serialise a link element"; 29 | 30 | #ifndef NDEBUG 31 | 32 | const ERRCODE NO_LIST = "Iterator not set to a list"; 33 | const ERRCODE NULL_OBJECT = "List found this = NULL!"; 34 | const ERRCODE NULL_DATA = "List would have returned a NULL data pointer"; 35 | const ERRCODE NULL_CURRENT = "List current position is NULL"; 36 | const ERRCODE NULL_NEXT = "Next element on the list is NULL"; 37 | const ERRCODE NULL_PREV = "Previous element on the list is NULL"; 38 | const ERRCODE EMPTY_LIST = "List is empty"; 39 | const ERRCODE BAD_PARAMETER = "List parameter error"; 40 | const ERRCODE STILL_LINKED = 41 | "Attemting to add an element with non NULL links, to a list"; 42 | #endif 43 | #endif 44 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/tfacepp.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: tfacepp.h (Formerly tface++.h) 3 | * Description: C++ side of the C/C++ Tess/Editor interface. 4 | * Author: Ray Smith 5 | * Created: Thu Apr 23 15:39:23 BST 1992 6 | * 7 | * (C) Copyright 1992, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TFACEPP_H 21 | #define TFACEPP_H 22 | 23 | #include "ratngs.h" 24 | #include "blobs.h" 25 | #include "notdll.h" 26 | #include "tesseractclass.h" 27 | 28 | void call_tester( //call a tester 29 | TBLOB *tessblob, //blob to test 30 | BOOL8 correct_blob, //true if good 31 | char *text, //source text 32 | inT32 count, //chars in text 33 | LIST result //output of matcher 34 | ); 35 | void call_train_tester( //call a tester 36 | TBLOB *tessblob, //blob to test 37 | BOOL8 correct_blob, //true if good 38 | char *text, //source text 39 | inT32 count, //chars in text 40 | LIST result //output of matcher 41 | ); 42 | #endif 43 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/leptwin.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifdef _WIN32 28 | #ifndef LEPTONICA_LEPTWIN_H 29 | #define LEPTONICA_LEPTWIN_H 30 | 31 | #include "allheaders.h" 32 | #include 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif /* __cplusplus */ 37 | 38 | LEPT_DLL extern HBITMAP pixGetWindowsHBITMAP( PIX *pixs ); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif /* __cplusplus */ 43 | 44 | #endif /* LEPTONICA_LEPTWIN_H */ 45 | #endif /* _WIN32 */ 46 | -------------------------------------------------------------------------------- /OCR-Example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // OCR-Example 4 | // 5 | // Created by Christopher Constable on 5/10/13. 6 | // Copyright (c) 2013 Christopher Constable. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/bits16.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: bits16.h (Formerly bits8.h) 3 | * Description: Code for 8 bit field class. 4 | * Author: Phil Cheatle 5 | * Created: Thu Oct 17 10:10:05 BST 1991 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef BITS16_H 21 | #define BITS16_H 22 | 23 | #include "host.h" 24 | 25 | class DLLSYM BITS16 26 | { 27 | public: 28 | uinT16 val; 29 | 30 | BITS16() { 31 | val = 0; 32 | } // constructor 33 | 34 | BITS16( // constructor 35 | uinT16 init); // initial val 36 | 37 | void turn_on_bit( // flip specified bit 38 | uinT8 bit_num) { // bit to flip 0..7 39 | val = val | 01 << bit_num; 40 | }; 41 | 42 | void turn_off_bit( // flip specified bit 43 | uinT8 bit_num) { // bit to flip 0..7 44 | val = val & ~(01 << bit_num); 45 | }; 46 | 47 | void set_bit( // flip specified bit 48 | uinT8 bit_num, // bit to flip 0..7 49 | BOOL8 value) { // value to flip to 50 | if (value) 51 | val = val | 01 << bit_num; 52 | else 53 | val = val & ~(01 << bit_num); 54 | }; 55 | 56 | BOOL8 bit( // access bit 57 | uinT8 bit_num) const { // bit to access 58 | return (val >> bit_num) & 01; 59 | }; 60 | }; 61 | #endif 62 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/platform.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: platform.h 3 | // Description: Place holder 4 | // Author: 5 | // Created: 6 | // 7 | // (C) Copyright 2006, Google Inc. 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | /////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef TESSERACT_CCUTIL_PLATFORM_H__ 21 | #define TESSERACT_CCUTIL_PLATFORM_H__ 22 | 23 | #define DLLSYM 24 | #ifdef _WIN32 25 | #ifdef __GNUC__ 26 | #define ultoa _ultoa 27 | typedef struct _BLOB { 28 | unsigned int cbSize; 29 | char *pBlobData; 30 | } BLOB, *LPBLOB; 31 | #endif /* __GNUC__ */ 32 | #define SIGNED 33 | #define snprintf _snprintf 34 | #if (_MSC_VER <= 1400) 35 | #define vsnprintf _vsnprintf 36 | #endif /* _WIN32 */ 37 | #else 38 | #define __UNIX__ 39 | #include 40 | #ifndef PATH_MAX 41 | #define MAX_PATH 4096 42 | #else 43 | #define MAX_PATH PATH_MAX 44 | #endif 45 | #define SIGNED signed 46 | #endif 47 | 48 | #if defined(_WIN32) || defined(__CYGWIN__) 49 | #if defined(TESS_EXPORTS) 50 | #define TESS_API __declspec(dllexport) 51 | #elif defined(TESS_IMPORTS) 52 | #define TESS_API __declspec(dllimport) 53 | #else 54 | #define TESS_API 55 | #endif 56 | #define TESS_LOCAL 57 | #else 58 | #if __GNUC__ >= 4 59 | #if defined(TESS_EXPORTS) || defined(TESS_IMPORTS) 60 | #define TESS_API __attribute__ ((visibility ("default"))) 61 | #define TESS_LOCAL __attribute__ ((visibility ("hidden"))) 62 | #else 63 | #define TESS_API 64 | #define TESS_LOCAL 65 | #endif 66 | #else 67 | #define TESS_API 68 | #define TESS_LOCAL 69 | #endif 70 | #endif 71 | 72 | #endif // TESSERACT_CCUTIL_PLATFORM_H__ 73 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/quadratc.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: quadratc.h (Formerly quadrtic.h) 3 | * Description: Code for the QUAD_COEFFS class. 4 | * Author: Ray Smith 5 | * Created: Tue Oct 08 17:24:40 BST 1991 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef QUADRATC_H 21 | #define QUADRATC_H 22 | 23 | #include "points.h" 24 | 25 | class QUAD_COEFFS 26 | { 27 | public: 28 | QUAD_COEFFS() { 29 | } //empty constructor 30 | QUAD_COEFFS( //constructor 31 | double xsq, //coefficients 32 | float x, 33 | float constant) { 34 | a = xsq; 35 | b = x; 36 | c = constant; 37 | } 38 | 39 | float y( //evaluate 40 | float x) const { //at x 41 | return (float) ((a * x + b) * x + c); 42 | } 43 | 44 | void move( // reposition word 45 | ICOORD vec) { // by vector 46 | /************************************************************ 47 | y - q = a (x - p)^2 + b (x - p) + c 48 | y - q = ax^2 - 2apx + ap^2 + bx - bp + c 49 | y = ax^2 + (b - 2ap)x + (c - bp + ap^2 + q) 50 | ************************************************************/ 51 | inT16 p = vec.x (); 52 | inT16 q = vec.y (); 53 | 54 | c = (float) (c - b * p + a * p * p + q); 55 | b = (float) (b - 2 * a * p); 56 | } 57 | 58 | double a; //x squared 59 | float b; //x 60 | float c; //constant 61 | private: 62 | }; 63 | #endif 64 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/alltypes.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef LEPTONICA_ALLTYPES_H 28 | #define LEPTONICA_ALLTYPES_H 29 | 30 | /* Standard */ 31 | #include 32 | #include 33 | 34 | /* General and configuration defs */ 35 | #include "environ.h" 36 | 37 | /* Imaging */ 38 | #include "array.h" 39 | #include "arrayaccess.h" 40 | #include "bbuffer.h" 41 | #include "bmf.h" 42 | #include "ccbord.h" 43 | #include "dewarp.h" 44 | #include "gplot.h" 45 | #include "heap.h" 46 | #include "imageio.h" 47 | #include "jbclass.h" 48 | #include "list.h" 49 | #include "morph.h" 50 | #include "pix.h" 51 | #include "ptra.h" 52 | #include "queue.h" 53 | #include "regutils.h" 54 | #include "sudoku.h" 55 | #include "stack.h" 56 | #include "watershed.h" 57 | 58 | 59 | #endif /* LEPTONICA_ALLTYPES_H */ 60 | 61 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/quadlsq.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: quadlsq.h (Formerly qlsq.h) 3 | * Description: Code for least squares approximation of quadratics. 4 | * Author: Ray Smith 5 | * Created: Wed Oct 6 15:14:23 BST 1993 6 | * 7 | * (C) Copyright 1993, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef QUADLSQ_H 21 | #define QUADLSQ_H 22 | 23 | #include "points.h" 24 | 25 | class QLSQ 26 | { 27 | public: 28 | QLSQ() { //constructor 29 | clear(); //set to zeros 30 | } 31 | void clear(); //initialize 32 | 33 | void add( //add element 34 | double x, //coords to add 35 | double y); 36 | void remove( //delete element 37 | double x, //coords to delete 38 | double y); 39 | inT32 count() { //no of elements 40 | return n; 41 | } 42 | 43 | void fit( //fit the given 44 | int degree); //return actual 45 | double get_a() { //get x squard 46 | return a; 47 | } 48 | double get_b() { //get x squard 49 | return b; 50 | } 51 | double get_c() { //get x squard 52 | return c; 53 | } 54 | 55 | private: 56 | inT32 n; //no of elements 57 | double a, b, c; //result 58 | double sigx; //sum of x 59 | double sigy; //sum of y 60 | double sigxx; //sum x squared 61 | double sigxy; //sum of xy 62 | double sigyy; //sum y squared 63 | long double sigxxx; //sum x cubed 64 | long double sigxxy; //sum xsquared y 65 | long double sigxxxx; //sum x fourth 66 | }; 67 | #endif 68 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/scanutils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Google Inc. 2 | // All Rights Reserved. 3 | // Author: renn 4 | // 5 | // Contains file io functions (mainly for file parsing), that might not be 6 | // available, on embedded devices, or that have an incomplete implementation 7 | // there. 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | #ifndef TESSERACT_CCUTIL_SCANUTILS_H_ 20 | #define TESSERACT_CCUTIL_SCANUTILS_H_ 21 | 22 | #ifdef EMBEDDED 23 | 24 | #include 25 | #include 26 | #include 27 | //#include 28 | #include 29 | 30 | // Attempts to parse the given file stream s as an integer of the base 31 | // 'base'. Returns the first successfully parsed integer as a uintmax_t, or 32 | // 0, if none was found. 33 | uintmax_t streamtoumax(FILE* s, int base); 34 | 35 | // Parse a file stream according to the given format. See the fscanf manpage 36 | // for more information, as this function attempts to mimic its behavior. 37 | // Note that scientific loating-point notation is not supported. 38 | int fscanf(FILE* stream, const char *format, ...); 39 | 40 | // Parse a file stream according to the given format. See the fscanf manpage 41 | // for more information, as this function attempts to mimic its behavior. 42 | // Note that scientific loating-point notation is not supported. 43 | int vfscanf(FILE* stream, const char *format, va_list ap); 44 | 45 | // Create a file at the specified path. See the creat manpage for more 46 | // information, as this function attempts to mimic its behavior. 47 | int creat(const char *pathname, mode_t mode); 48 | 49 | // Convert the specified C-String to a float. Returns the first parsed float, 50 | // or 0.0 if no floating point value could be found. Note that scientific 51 | // floating-point notation is not supported. 52 | double strtofloat(const char* s); 53 | 54 | #endif // EMBEDDED 55 | 56 | #endif // TESSERACT_CCUTIL_SCANUTILS_H_ 57 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/bbuffer.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef LEPTONICA_BBUFFER_H 28 | #define LEPTONICA_BBUFFER_H 29 | 30 | /* 31 | * bbuffer.h 32 | * 33 | * Expandable byte buffer for reading data in from memory and 34 | * writing data out to other memory. 35 | * 36 | * This implements a queue of bytes, so data read in is put 37 | * on the "back" of the queue (i.e., the end of the byte array) 38 | * and data written out is taken from the "front" of the queue 39 | * (i.e., from an index marker "nwritten" that is initially set at 40 | * the beginning of the array.) As usual with expandable 41 | * arrays, we keep the size of the allocated array and the 42 | * number of bytes that have been read into the array. 43 | * 44 | * For implementation details, see bbuffer.c. 45 | */ 46 | 47 | struct ByteBuffer 48 | { 49 | l_int32 nalloc; /* size of allocated byte array */ 50 | l_int32 n; /* number of bytes read into to the array */ 51 | l_int32 nwritten; /* number of bytes written from the array */ 52 | l_uint8 *array; /* byte array */ 53 | }; 54 | typedef struct ByteBuffer BBUFFER; 55 | 56 | 57 | #endif /* LEPTONICA_BBUFFER_H */ 58 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/boxread.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: boxread.cpp 3 | * Description: Read data from a box file. 4 | * Author: Ray Smith 5 | * Created: Fri Aug 24 17:47:23 PDT 2007 6 | * 7 | * (C) Copyright 2007, Google Inc. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TESSERACT_CCUTIL_BOXREAD_H__ 21 | #define TESSERACT_CCUTIL_BOXREAD_H__ 22 | 23 | #include 24 | #include "strngs.h" 25 | 26 | class STRING; 27 | class TBOX; 28 | 29 | // Size of buffer used to read a line from a box file. 30 | const int kBoxReadBufSize = 1024; 31 | 32 | // Open the boxfile based on the given image filename. 33 | FILE* OpenBoxFile(const STRING& fname); 34 | 35 | // ReadNextBox factors out the code to interpret a line of a box 36 | // file so that applybox and unicharset_extractor interpret the same way. 37 | // This function returns the next valid box file utf8 string and coords 38 | // and returns true, or false on eof (and closes the file). 39 | // It ignores the utf8 file signature ByteOrderMark (U+FEFF=EF BB BF), checks 40 | // for valid utf-8 and allows space or tab between fields. 41 | // utf8_str is set with the unichar string, and bounding box with the box. 42 | // If there are page numbers in the file, it reads them all. 43 | bool ReadNextBox(int *line_number, FILE* box_file, 44 | STRING* utf8_str, TBOX* bounding_box); 45 | // As ReadNextBox above, but get a specific page number. (0-based) 46 | // Use -1 to read any page number. Files without page number all 47 | // read as if they are page 0. 48 | bool ReadNextBox(int target_page, int *line_number, FILE* box_file, 49 | STRING* utf8_str, TBOX* bounding_box); 50 | 51 | // Parses the given box file string into a page_number, utf8_str, and 52 | // bounding_box. Returns true on a successful parse. 53 | bool ParseBoxFileStr(const char* boxfile_str, int* page_number, 54 | STRING* utf8_str, TBOX* bounding_box); 55 | 56 | // Creates a box file string from a unichar string, TBOX and page number. 57 | void MakeBoxFileStr(const char* unichar_str, const TBOX& box, int page_num, 58 | STRING* box_str); 59 | 60 | #endif // TESSERACT_CCUTIL_BOXREAD_H__ 61 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/otsuthr.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: otsuthr.h 3 | // Description: Simple Otsu thresholding for binarizing images. 4 | // Author: Ray Smith 5 | // Created: Fri Mar 07 12:14:01 PST 2008 6 | // 7 | // (C) Copyright 2008, Google Inc. 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | /////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef TESSERACT_CCMAIN_OTSUTHR_H__ 21 | #define TESSERACT_CCMAIN_OTSUTHR_H__ 22 | 23 | namespace tesseract { 24 | 25 | const int kHistogramSize = 256; // The size of a histogram of pixel values. 26 | 27 | // Compute the Otsu threshold(s) for the given image rectangle, making one 28 | // for each channel. Each channel is always one byte per pixel. 29 | // Returns an array of threshold values and an array of hi_values, such 30 | // that a pixel value >threshold[channel] is considered foreground if 31 | // hi_values[channel] is 0 or background if 1. A hi_value of -1 indicates 32 | // that there is no apparent foreground. At least one hi_value will not be -1. 33 | // Delete thresholds and hi_values with delete [] after use. 34 | void OtsuThreshold(const unsigned char* imagedata, 35 | int bytes_per_pixel, int bytes_per_line, 36 | int left, int top, int width, int height, 37 | int** thresholds, int** hi_values); 38 | 39 | // Compute the histogram for the given image rectangle, and the given 40 | // channel. (Channel pointed to by imagedata.) Each channel is always 41 | // one byte per pixel. 42 | // Bytes per pixel is used to skip channels not being 43 | // counted with this call in a multi-channel (pixel-major) image. 44 | // Histogram is always a 256 element array to count occurrences of 45 | // each pixel value. 46 | void HistogramRect(const unsigned char* imagedata, 47 | int bytes_per_pixel, int bytes_per_line, 48 | int left, int top, int width, int height, 49 | int* histogram); 50 | 51 | // Compute the Otsu threshold(s) for the given histogram. 52 | // Also returns H = total count in histogram, and 53 | // omega0 = count of histogram below threshold. 54 | int OtsuStats(const int* histogram, int* H_out, int* omega0_out); 55 | 56 | } // namespace tesseract. 57 | 58 | #endif // TESSERACT_CCMAIN_OTSUTHR_H__ 59 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/mutableiterator.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: mutableiterator.h 3 | // Description: Iterator for tesseract results providing access to 4 | // both high-level API and Tesseract internal data structures. 5 | // Author: David Eger 6 | // Created: Thu Feb 24 19:01:06 PST 2011 7 | // 8 | // (C) Copyright 2011, Google Inc. 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // http://www.apache.org/licenses/LICENSE-2.0 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | /////////////////////////////////////////////////////////////////////// 20 | 21 | #ifndef TESSERACT_CCMAIN_MUTABLEITERATOR_H__ 22 | #define TESSERACT_CCMAIN_MUTABLEITERATOR_H__ 23 | 24 | #include "resultiterator.h" 25 | 26 | class BLOB_CHOICE_IT; 27 | 28 | namespace tesseract { 29 | 30 | class Tesseract; 31 | 32 | // Class to iterate over tesseract results, providing access to all levels 33 | // of the page hierarchy, without including any tesseract headers or having 34 | // to handle any tesseract structures. 35 | // WARNING! This class points to data held within the TessBaseAPI class, and 36 | // therefore can only be used while the TessBaseAPI class still exists and 37 | // has not been subjected to a call of Init, SetImage, Recognize, Clear, End 38 | // DetectOS, or anything else that changes the internal PAGE_RES. 39 | // See apitypes.h for the definition of PageIteratorLevel. 40 | // See also base class PageIterator, which contains the bulk of the interface. 41 | // ResultIterator adds text-specific methods for access to OCR output. 42 | // MutableIterator adds access to internal data structures. 43 | 44 | class MutableIterator : public ResultIterator { 45 | public: 46 | // See argument descriptions in ResultIterator() 47 | MutableIterator(PAGE_RES* page_res, Tesseract* tesseract, 48 | int scale, int scaled_yres, 49 | int rect_left, int rect_top, 50 | int rect_width, int rect_height) 51 | : ResultIterator( 52 | LTRResultIterator(page_res, tesseract, scale, scaled_yres, rect_left, 53 | rect_top, rect_width, rect_height)) {} 54 | virtual ~MutableIterator() {} 55 | 56 | // See PageIterator and ResultIterator for most calls. 57 | 58 | // Return access to Tesseract internals. 59 | const PAGE_RES_IT *PageResIt() const { return it_; } 60 | }; 61 | 62 | } // namespace tesseract. 63 | 64 | #endif // TESSERACT_CCMAIN_MUTABLEITERATOR_H__ 65 | -------------------------------------------------------------------------------- /OCR-Example/ResultsViewController.mm: -------------------------------------------------------------------------------- 1 | // 2 | // ResultsViewController.m 3 | // OCR-Example 4 | // 5 | // Created by Christopher Constable on 5/10/13. 6 | // Copyright (c) 2013 Christopher Constable. All rights reserved. 7 | // 8 | 9 | #import "ResultsViewController.h" 10 | #import "Tesseract.h" 11 | #import "ImageProcessing.h" 12 | 13 | @interface ResultsViewController () 14 | 15 | @end 16 | 17 | @implementation ResultsViewController 18 | 19 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 20 | { 21 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 22 | if (self) { 23 | // Custom initialization 24 | } 25 | return self; 26 | } 27 | 28 | - (void)viewDidLoad 29 | { 30 | [super viewDidLoad]; 31 | } 32 | 33 | - (void)viewDidAppear:(BOOL)animated 34 | { 35 | [super viewDidAppear:animated]; 36 | 37 | // Process the image. 38 | // Ideally, this shouldn't happen everytime the view appears but its a 39 | // sample. 40 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ 41 | __block Tesseract* tesseract = [[Tesseract alloc] initWithDataPath:@"/tessdata" language:@"eng"]; 42 | 43 | // Uncomment to only search for alpha-numeric characters. 44 | [tesseract setVariableValue:@"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" forKey:@"tessedit_char_whitelist"]; 45 | 46 | // Shrink the image. Tesseract works better with smaller images than what the iPhone puts out. 47 | CGSize newSize = CGSizeMake(self.selectedImage.size.width / 3, self.selectedImage.size.height / 3); 48 | UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0); 49 | [self.selectedImage drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; 50 | UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 51 | UIGraphicsEndImageContext(); 52 | 53 | ImageWrapper *greyScale=Image::createImage(resizedImage, resizedImage.size.width, resizedImage.size.height); 54 | ImageWrapper *edges = greyScale.image->autoLocalThreshold(); 55 | 56 | [tesseract setImage:edges.image->toUIImage()]; 57 | [tesseract recognize]; 58 | 59 | dispatch_async(dispatch_get_main_queue(), ^{ 60 | [UIView animateWithDuration:0.3 61 | animations:^{ 62 | self.loadingView.alpha = 0.0; 63 | } 64 | completion:^(BOOL finished) { 65 | self.loadingView.hidden = YES; 66 | [self.resultsTextView setText:[tesseract recognizedText]]; 67 | }]; 68 | }); 69 | }); 70 | } 71 | 72 | - (void)didReceiveMemoryWarning 73 | { 74 | [super didReceiveMemoryWarning]; 75 | // Dispose of any resources that can be recreated. 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/vecfuncs.h: -------------------------------------------------------------------------------- 1 | /* -*-C-*- 2 | ******************************************************************************** 3 | * 4 | * File: vecfuncs.h (Formerly vecfuncs.h) 5 | * Description: Vector calculations 6 | * Author: Mark Seaman, OCR Technology 7 | * Created: Wed Dec 20 09:37:18 1989 8 | * Modified: Tue Jul 9 17:44:37 1991 (Mark Seaman) marks@hpgrlt 9 | * Language: C 10 | * Package: N/A 11 | * Status: Experimental (Do Not Distribute) 12 | * 13 | * (c) Copyright 1989, Hewlett-Packard Company. 14 | ** Licensed under the Apache License, Version 2.0 (the "License"); 15 | ** you may not use this file except in compliance with the License. 16 | ** You may obtain a copy of the License at 17 | ** http://www.apache.org/licenses/LICENSE-2.0 18 | ** Unless required by applicable law or agreed to in writing, software 19 | ** distributed under the License is distributed on an "AS IS" BASIS, 20 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | ** See the License for the specific language governing permissions and 22 | ** limitations under the License. 23 | * 24 | *********************************************************************************/ 25 | #ifndef VECFUNCS_H 26 | #define VECFUNCS_H 27 | 28 | #include 29 | #include "blobs.h" 30 | 31 | class EDGEPT; 32 | 33 | /*---------------------------------------------------------------------- 34 | M a c r o s 35 | ----------------------------------------------------------------------*/ 36 | /********************************************************************** 37 | * point_diff 38 | * 39 | * Return the difference from point (p1) to point (p2). Put the value 40 | * into point (p). 41 | **********************************************************************/ 42 | 43 | #define point_diff(p,p1,p2) \ 44 | ((p).x = (p1).x - (p2).x, \ 45 | (p).y = (p1).y - (p2).y, \ 46 | (p)) 47 | 48 | /********************************************************************** 49 | * CROSS 50 | * 51 | * cross product 52 | **********************************************************************/ 53 | 54 | #define CROSS(a,b) \ 55 | ((a).x * (b).y - (a).y * (b).x) 56 | 57 | /********************************************************************** 58 | * SCALAR 59 | * 60 | * scalar vector product 61 | **********************************************************************/ 62 | 63 | #define SCALAR(a,b) \ 64 | ((a).x * (b).x + (a).y * (b).y) 65 | 66 | /********************************************************************** 67 | * LENGTH 68 | * 69 | * length of vector 70 | **********************************************************************/ 71 | 72 | #define LENGTH(a) \ 73 | ((a).x * (a).x + (a).y * (a).y) 74 | 75 | /*---------------------------------------------------------------------- 76 | F u n c t i o n s 77 | ----------------------------------------------------------------------*/ 78 | int direction(EDGEPT *point); 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/mod128.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: mod128.h (Formerly dir128.h) 3 | * Description: Header for class which implements modulo arithmetic. 4 | * Author: Ray Smith 5 | * Created: Tue Mar 26 17:48:13 GMT 1991 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef MOD128_H 21 | #define MOD128_H 22 | 23 | #include "points.h" 24 | 25 | #define MODULUS 128 /*range of directions */ 26 | #define DIRBITS 7 //no of bits used 27 | #define DIRSCALE 1000 //length of vector 28 | 29 | class DLLSYM DIR128 30 | { 31 | public: 32 | DIR128() { 33 | } //empty constructor 34 | 35 | DIR128( //constructor 36 | inT16 value) { //value to assign 37 | value %= MODULUS; //modulo arithmetic 38 | if (value < 0) 39 | value += MODULUS; //done properly 40 | dir = (inT8) value; 41 | } 42 | DIR128(const FCOORD fc); //quantize vector 43 | 44 | DIR128 & operator= ( //assign of inT16 45 | inT16 value) { //value to assign 46 | value %= MODULUS; //modulo arithmetic 47 | if (value < 0) 48 | value += MODULUS; //done properly 49 | dir = (inT8) value; 50 | return *this; 51 | } 52 | inT8 operator- ( //subtraction 53 | const DIR128 & minus) const//for signed result 54 | { 55 | //result 56 | inT16 result = dir - minus.dir; 57 | 58 | if (result > MODULUS / 2) 59 | result -= MODULUS; //get in range 60 | else if (result < -MODULUS / 2) 61 | result += MODULUS; 62 | return (inT8) result; 63 | } 64 | DIR128 operator+ ( //addition 65 | const DIR128 & add) const //of itself 66 | { 67 | DIR128 result; //sum 68 | 69 | result = dir + add.dir; //let = do the work 70 | return result; 71 | } 72 | DIR128 & operator+= ( //same as + 73 | const DIR128 & add) { 74 | *this = dir + add.dir; //let = do the work 75 | return *this; 76 | } 77 | inT8 get_dir() const { //access function 78 | return dir; 79 | } 80 | ICOORD vector() const; //turn to vector 81 | 82 | private: 83 | inT8 dir; //a direction 84 | }; 85 | #endif 86 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/cubeclassifier.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // Author: rays@google.com (Ray Smith) 3 | /////////////////////////////////////////////////////////////////////// 4 | // File: cubeclassifier.h 5 | // Description: Cube implementation of a ShapeClassifier. 6 | // Author: Ray Smith 7 | // Created: Wed Nov 23 10:36:32 PST 2011 8 | // 9 | // (C) Copyright 2011, Google Inc. 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // Unless required by applicable law or agreed to in writing, software 15 | // distributed under the License is distributed on an "AS IS" BASIS, 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | // See the License for the specific language governing permissions and 18 | // limitations under the License. 19 | // 20 | /////////////////////////////////////////////////////////////////////// 21 | 22 | #ifndef THIRD_PARTY_TESSERACT_CCMAIN_CUBECLASSIFIER_H_ 23 | #define THIRD_PARTY_TESSERACT_CCMAIN_CUBECLASSIFIER_H_ 24 | 25 | #include "shapeclassifier.h" 26 | 27 | namespace tesseract { 28 | 29 | class Classify; 30 | class CubeRecoContext; 31 | class ShapeTable; 32 | class TessClassifier; 33 | class Tesseract; 34 | class TrainingSample; 35 | 36 | // Cube implementation of a ShapeClassifier. 37 | class CubeClassifier : public ShapeClassifier { 38 | public: 39 | explicit CubeClassifier(Tesseract* tesseract); 40 | virtual ~CubeClassifier(); 41 | 42 | // Classifies the given [training] sample, writing to results. 43 | // See ShapeClassifier for a full description. 44 | virtual int ClassifySample(const TrainingSample& sample, Pix* page_pix, 45 | int debug, int keep_this, 46 | GenericVector* results); 47 | // Provides access to the ShapeTable that this classifier works with. 48 | virtual const ShapeTable* GetShapeTable() const; 49 | 50 | private: 51 | // Cube objects. 52 | CubeRecoContext* cube_cntxt_; 53 | const ShapeTable& shape_table_; 54 | }; 55 | 56 | // Combination of Tesseract class pruner with scoring by cube. 57 | class CubeTessClassifier : public ShapeClassifier { 58 | public: 59 | explicit CubeTessClassifier(Tesseract* tesseract); 60 | virtual ~CubeTessClassifier(); 61 | 62 | // Classifies the given [training] sample, writing to results. 63 | // See ShapeClassifier for a full description. 64 | virtual int ClassifySample(const TrainingSample& sample, Pix* page_pix, 65 | int debug, int keep_this, 66 | GenericVector* results); 67 | // Provides access to the ShapeTable that this classifier works with. 68 | virtual const ShapeTable* GetShapeTable() const; 69 | 70 | private: 71 | // Cube objects. 72 | CubeRecoContext* cube_cntxt_; 73 | const ShapeTable& shape_table_; 74 | TessClassifier* pruner_; 75 | }; 76 | 77 | } // namespace tesseract 78 | 79 | #endif /* THIRD_PARTY_TESSERACT_CCMAIN_CUBECLASSIFIER_H_ */ 80 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/stepblob.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: stepblob.h (Formerly cblob.h) 3 | * Description: Code for C_BLOB class. 4 | * Author: Ray Smith 5 | * Created: Tue Oct 08 10:41:13 BST 1991 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef STEPBLOB_H 21 | #define STEPBLOB_H 22 | 23 | #include "coutln.h" 24 | #include "rect.h" 25 | 26 | struct Pix; 27 | 28 | class C_BLOB:public ELIST_LINK 29 | { 30 | public: 31 | C_BLOB() { 32 | } 33 | explicit C_BLOB(C_OUTLINE_LIST *outline_list); 34 | // Simpler constructor to build a blob from a single outline that has 35 | // already been fully initialized. 36 | explicit C_BLOB(C_OUTLINE* outline); 37 | 38 | // Build and return a fake blob containing a single fake outline with no 39 | // steps. 40 | static C_BLOB* FakeBlob(const TBOX& box); 41 | 42 | C_OUTLINE_LIST *out_list() { //get outline list 43 | return &outlines; 44 | } 45 | 46 | TBOX bounding_box(); //compute bounding box 47 | inT32 area(); //compute area 48 | inT32 perimeter(); // Total perimeter of outlines and 1st level children. 49 | inT32 outer_area(); //compute area 50 | inT32 count_transitions( //count maxima 51 | inT32 threshold); //size threshold 52 | 53 | void move(const ICOORD vec); // repostion blob by vector 54 | void rotate(const FCOORD& rotation); // Rotate by given vector. 55 | 56 | // Returns a Pix rendering of the blob. pixDestroy after use. 57 | Pix* render(); 58 | // Returns a Pix rendering of the outline of the blob. (no fill). 59 | // pixDestroy after use. 60 | Pix* render_outline(); 61 | 62 | #ifndef GRAPHICS_DISABLED 63 | void plot( //draw one 64 | ScrollView* window, //window to draw in 65 | ScrollView::Color blob_colour, //for outer bits 66 | ScrollView::Color child_colour); //for holes 67 | #endif // GRAPHICS_DISABLED 68 | 69 | C_BLOB& operator= (const C_BLOB & source) { 70 | if (!outlines.empty ()) 71 | outlines.clear(); 72 | outlines.deep_copy(&source.outlines, &C_OUTLINE::deep_copy); 73 | return *this; 74 | } 75 | 76 | static C_BLOB* deep_copy(const C_BLOB* src) { 77 | C_BLOB* blob = new C_BLOB; 78 | *blob = *src; 79 | return blob; 80 | } 81 | 82 | private: 83 | C_OUTLINE_LIST outlines; //master elements 84 | }; 85 | 86 | ELISTIZEH (C_BLOB) 87 | #endif 88 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/bmf.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef LEPTONICA_BMF_H 28 | #define LEPTONICA_BMF_H 29 | 30 | /* 31 | * bmf.h 32 | * 33 | * Simple data structure to hold bitmap fonts and related data 34 | */ 35 | 36 | /* Constants for deciding when text block is divided into paragraphs */ 37 | enum { 38 | SPLIT_ON_LEADING_WHITE = 1, /* tab or space at beginning of line */ 39 | SPLIT_ON_BLANK_LINE = 2, /* newline with optional white space */ 40 | SPLIT_ON_BOTH = 3 /* leading white space or newline */ 41 | }; 42 | 43 | 44 | struct L_Bmf 45 | { 46 | struct Pixa *pixa; /* pixa of bitmaps for 93 characters */ 47 | l_int32 size; /* font size (in points at 300 ppi) */ 48 | char *directory; /* directory containing font bitmaps */ 49 | l_int32 baseline1; /* baseline offset for ascii 33 - 57 */ 50 | l_int32 baseline2; /* baseline offset for ascii 58 - 91 */ 51 | l_int32 baseline3; /* baseline offset for ascii 93 - 126 */ 52 | l_int32 lineheight; /* max height of line of chars */ 53 | l_int32 kernwidth; /* pixel dist between char bitmaps */ 54 | l_int32 spacewidth; /* pixel dist between word bitmaps */ 55 | l_int32 vertlinesep; /* extra vertical space between text lines */ 56 | l_int32 *fonttab; /* table mapping ascii --> font index */ 57 | l_int32 *baselinetab; /* table mapping ascii --> baseline offset */ 58 | l_int32 *widthtab; /* table mapping ascii --> char width */ 59 | }; 60 | typedef struct L_Bmf L_BMF; 61 | 62 | #endif /* LEPTONICA_BMF_H */ 63 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/stack.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef LEPTONICA_STACK_H 28 | #define LEPTONICA_STACK_H 29 | 30 | /* 31 | * stack.h 32 | * 33 | * Expandable pointer stack for arbitrary void* data. 34 | * 35 | * The L_Stack is an array of void * ptrs, onto which arbitrary 36 | * objects can be stored. At any time, the number of 37 | * stored objects is stack->n. The object at the bottom 38 | * of the stack is at array[0]; the object at the top of 39 | * the stack is at array[n-1]. New objects are added 40 | * to the top of the stack, at the first available location, 41 | * which is array[n]. Objects are removed from the top of the 42 | * stack. When an attempt is made to remove an object from an 43 | * empty stack, the result is null. When the stack becomes 44 | * filled, so that n = nalloc, the size is doubled. 45 | * 46 | * The auxiliary stack can be used to store and remove 47 | * objects for re-use. It must be created by a separate 48 | * call to pstackCreate(). [Just imagine the chaos if 49 | * pstackCreate() created the auxiliary stack!] 50 | * pstackDestroy() checks for the auxiliary stack and removes it. 51 | */ 52 | 53 | 54 | /* Note that array[n] is the first null ptr in the array */ 55 | struct L_Stack 56 | { 57 | l_int32 nalloc; /* size of ptr array */ 58 | l_int32 n; /* number of stored elements */ 59 | void **array; /* ptr array */ 60 | struct L_Stack *auxstack; /* auxiliary stack */ 61 | }; 62 | typedef struct L_Stack L_STACK; 63 | 64 | 65 | #endif /* LEPTONICA_STACK_H */ 66 | 67 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/ccutil.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: ccutil.h 3 | // Description: ccutil class. 4 | // Author: Samuel Charron 5 | // 6 | // (C) Copyright 2006, Google Inc. 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | /////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef TESSERACT_CCUTIL_CCUTIL_H__ 20 | #define TESSERACT_CCUTIL_CCUTIL_H__ 21 | 22 | #include "ambigs.h" 23 | #include "errcode.h" 24 | #include "strngs.h" 25 | #include "tessdatamanager.h" 26 | #include "params.h" 27 | #include "unicharset.h" 28 | 29 | #ifdef _WIN32 30 | #include 31 | #else 32 | #include 33 | #include 34 | #endif 35 | 36 | namespace tesseract { 37 | 38 | class CCUtilMutex { 39 | public: 40 | CCUtilMutex(); 41 | 42 | void Lock(); 43 | 44 | void Unlock(); 45 | private: 46 | #ifdef _WIN32 47 | HANDLE mutex_; 48 | #else 49 | pthread_mutex_t mutex_; 50 | #endif 51 | }; 52 | 53 | 54 | class CCUtil { 55 | public: 56 | CCUtil(); 57 | virtual ~CCUtil(); 58 | 59 | public: 60 | // Read the arguments and set up the data path. 61 | void main_setup( 62 | const char *argv0, // program name 63 | const char *basename // name of image 64 | ); 65 | ParamsVectors *params() { return ¶ms_; } 66 | 67 | STRING datadir; // dir for data files 68 | STRING imagebasename; // name of image 69 | STRING lang; 70 | STRING language_data_path_prefix; 71 | TessdataManager tessdata_manager; 72 | UNICHARSET unicharset; 73 | UnicharAmbigs unichar_ambigs; 74 | STRING imagefile; // image file name 75 | STRING directory; // main directory 76 | 77 | private: 78 | ParamsVectors params_; 79 | 80 | public: 81 | // Member parameters. 82 | // These have to be declared and initialized after params_ member, since 83 | // params_ should be initialized before parameters are added to it. 84 | STRING_VAR_H(m_data_sub_dir, "tessdata/", "Directory for data files"); 85 | #ifdef _WIN32 86 | STRING_VAR_H(tessedit_module_name, WINDLLNAME, 87 | "Module colocated with tessdata dir"); 88 | #endif 89 | INT_VAR_H(ambigs_debug_level, 0, "Debug level for unichar ambiguities"); 90 | BOOL_VAR_H(use_definite_ambigs_for_classifier, 0, 91 | "Use definite ambiguities when running character classifier"); 92 | BOOL_VAR_H(use_ambigs_for_adaption, 0, 93 | "Use ambigs for deciding whether to adapt to a character"); 94 | }; 95 | 96 | extern CCUtilMutex tprintfMutex; // should remain global 97 | } // namespace tesseract 98 | 99 | #endif // TESSERACT_CCUTIL_CCUTIL_H__ 100 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/unicharmap.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: unicharmap.h 3 | // Description: Unicode character/ligature to integer id class. 4 | // Author: Thomas Kielbus 5 | // Created: Wed Jun 28 17:05:01 PDT 2006 6 | // 7 | // (C) Copyright 2006, Google Inc. 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | /////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef TESSERACT_CCUTIL_UNICHARMAP_H__ 21 | #define TESSERACT_CCUTIL_UNICHARMAP_H__ 22 | 23 | #include "unichar.h" 24 | 25 | // A UNICHARMAP stores unique unichars. Each of them is associated with one 26 | // UNICHAR_ID. 27 | class UNICHARMAP { 28 | public: 29 | 30 | // Create an empty UNICHARMAP 31 | UNICHARMAP(); 32 | 33 | ~UNICHARMAP(); 34 | 35 | // Insert the given unichar represention in the UNICHARMAP and associate it 36 | // with the given id. The length of the representation MUST be non-zero. 37 | void insert(const char* const unichar_repr, UNICHAR_ID id); 38 | 39 | // Return the id associated with the given unichar representation, 40 | // this representation MUST exist within the UNICHARMAP. 41 | // The length of the representation MUST be non-zero. 42 | UNICHAR_ID unichar_to_id(const char* const unichar_repr) const; 43 | 44 | // Return the id associated with the given unichar representation, 45 | // this representation MUST exist within the UNICHARMAP. The first 46 | // length characters (maximum) from unichar_repr are used. The length 47 | // MUST be non-zero. 48 | UNICHAR_ID unichar_to_id(const char* const unichar_repr, int length) const; 49 | 50 | // Return true if the given unichar representation is already present in the 51 | // UNICHARMAP. The length of the representation MUST be non-zero. 52 | bool contains(const char* const unichar_repr) const; 53 | 54 | // Return true if the given unichar representation is already present in the 55 | // UNICHARMAP. The first length characters (maximum) from unichar_repr are 56 | // used. The length MUST be non-zero. 57 | bool contains(const char* const unichar_repr, int length) const; 58 | 59 | // Return the minimum number of characters that must be used from this string 60 | // to obtain a match in the UNICHARMAP. 61 | int minmatch(const char* const unichar_repr) const; 62 | 63 | // Clear the UNICHARMAP. All previous data is lost. 64 | void clear(); 65 | 66 | private: 67 | 68 | // The UNICHARMAP is represented as a tree whose nodes are of type 69 | // UNICHARMAP_NODE. 70 | struct UNICHARMAP_NODE { 71 | 72 | UNICHARMAP_NODE(); 73 | ~UNICHARMAP_NODE(); 74 | 75 | UNICHARMAP_NODE* children; 76 | UNICHAR_ID id; 77 | }; 78 | 79 | UNICHARMAP_NODE* nodes; 80 | }; 81 | 82 | #endif // TESSERACT_CCUTIL_UNICHARMAP_H__ 83 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/qrsequence.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: qrsequence.h 3 | // Description: Quasi-random sequence generator class. 4 | // Author: Ranjith Unnikrishnan 5 | // Created: Wed May 20 2009 6 | // 7 | // Class to generate a (deterministic) quasi-random Van der Corput sequence that 8 | // covers the interval [0,N) without repetition. 9 | // 10 | // The sequence is generated by reversing the base-2 representation of the 11 | // sequence of natural numbers {0, 1,... M-1}, where M is 2^{num_bits_} and 12 | // num_bits is the minimum number of bits required to represent N. If a reversed 13 | // numbers is >= N it is rejected and the next natural number is considered 14 | // until a valid output number is found. 15 | // 16 | // (C) Copyright 2009, Google Inc. 17 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 18 | // use this file except in compliance with the License. You may obtain a copy 19 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 20 | // by applicable law or agreed to in writing, software distributed under the 21 | // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 22 | // OF ANY KIND, either express or implied. See the License for the specific 23 | // language governing permissions and limitations under the License. 24 | // 25 | /////////////////////////////////////////////////////////////////////// 26 | 27 | #ifndef TESSERACT_CCUTIL_QRSEQUENCE_H_ 28 | #define TESSERACT_CCUTIL_QRSEQUENCE_H_ 29 | 30 | #include 31 | 32 | class QRSequenceGenerator { 33 | public: 34 | // Object is initalized with the size of the output range. 35 | explicit QRSequenceGenerator(int N) : N_(N), next_num_(0) { 36 | num_bits_ = static_cast(ceil(log(static_cast(N)) / log(2.0))); 37 | } 38 | 39 | // Main worker method that retrieves the next number in the sequence. 40 | // Returns kInvalidVal if called more than N times after object initialization 41 | int GetVal() { 42 | const int kInvalidVal = -1; 43 | const int kMaxNaturalNumberValue = 1 << num_bits_; 44 | if (next_num_ >= kMaxNaturalNumberValue) 45 | return kInvalidVal; 46 | int n = next_num_; 47 | 48 | while (next_num_ < kMaxNaturalNumberValue) { 49 | n = GetBinaryReversedInteger(next_num_++); 50 | if (n < N_) break; 51 | } 52 | return (next_num_ > kMaxNaturalNumberValue) ? kInvalidVal : n; 53 | } 54 | 55 | protected: 56 | // Outputs the integer formed by reversing the bits of the input integer. Only 57 | // the lowest num_bits_ bits of the input integer are reversed. 58 | int GetBinaryReversedInteger(int in_val) const { 59 | int bit_pos = num_bits_; 60 | int out_val = 0; 61 | while(bit_pos--) { 62 | // Set the value of the last bit. 63 | out_val |= (in_val & 0x1); 64 | if (bit_pos > 0) { 65 | // Left-shift output value to prepare for storing the next bit. 66 | out_val <<= 1; 67 | } 68 | // Right-shift input value to prepare for retrieving the next bit. 69 | in_val >>= 1; 70 | } 71 | return out_val; 72 | } 73 | int N_; 74 | // Next number to be considered for reversal and output. 75 | int next_num_; 76 | // number of bits required to represent the numbers of the sequence 77 | int num_bits_; 78 | }; 79 | 80 | #endif // TESSERACT_CCUTIL_QRSEQUENCE_H_ 81 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/linlsq.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: linlsq.h (Formerly llsq.h) 3 | * Description: Linear Least squares fitting code. 4 | * Author: Ray Smith 5 | * Created: Thu Sep 12 08:44:51 BST 1991 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TESSERACT_CCSTRUCT_LINLSQ_H_ 21 | #define TESSERACT_CCSTRUCT_LINLSQ_H_ 22 | 23 | #include "points.h" 24 | #include "params.h" 25 | 26 | class LLSQ { 27 | public: 28 | LLSQ() { // constructor 29 | clear(); // set to zeros 30 | } 31 | void clear(); // initialize 32 | 33 | // Adds an element with a weight of 1. 34 | void add(double x, double y); 35 | // Adds an element with a specified weight. 36 | void add(double x, double y, double weight); 37 | // Adds a whole LLSQ. 38 | void add(const LLSQ& other); 39 | // Deletes an element with a weight of 1. 40 | void remove(double x, double y); 41 | inT32 count() const { // no of elements 42 | return static_cast(total_weight + 0.5); 43 | } 44 | 45 | double m() const; // get gradient 46 | double c(double m) const; // get constant 47 | double rms(double m, double c) const; // get error 48 | double pearson() const; // get correlation coefficient. 49 | 50 | // Returns the x,y means as an FCOORD. 51 | FCOORD mean_point() const; 52 | // Returns the direction of the fitted line as a unit vector, using the 53 | // least mean squared perpendicular distance. The line runs through the 54 | // mean_point, i.e. a point p on the line is given by: 55 | // p = mean_point() + lambda * vector_fit() for some real number lambda. 56 | // Note that the result (0<=x<=1, -1<=y<=-1) is directionally ambiguous 57 | // and may be negated without changing its meaning. 58 | FCOORD vector_fit() const; 59 | // Returns the covariance. 60 | double covariance() const { 61 | if (total_weight > 0.0) 62 | return (sigxy - sigx * sigy / total_weight) / total_weight; 63 | else 64 | return 0.0; 65 | } 66 | double x_variance() const { 67 | if (total_weight > 0.0) 68 | return (sigxx - sigx * sigx / total_weight) / total_weight; 69 | else 70 | return 0.0; 71 | } 72 | double y_variance() const { 73 | if (total_weight > 0.0) 74 | return (sigyy - sigy * sigy / total_weight) / total_weight; 75 | else 76 | return 0.0; 77 | } 78 | 79 | private: 80 | double total_weight; // no of elements or sum of weights. 81 | double sigx; // sum of x 82 | double sigy; // sum of y 83 | double sigxx; // sum x squared 84 | double sigxy; // sum of xy 85 | double sigyy; // sum y squared 86 | }; 87 | 88 | #endif // TESSERACT_CCSTRUCT_LINLSQ_H_ 89 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/split.h: -------------------------------------------------------------------------------- 1 | /* -*-C-*- 2 | ******************************************************************************** 3 | * 4 | * File: split.h (Formerly split.h) 5 | * Description: 6 | * Author: Mark Seaman, SW Productivity 7 | * Created: Fri Oct 16 14:37:00 1987 8 | * Modified: Mon May 13 10:49:23 1991 (Mark Seaman) marks@hpgrlt 9 | * Language: C 10 | * Package: N/A 11 | * Status: Reusable Software Component 12 | * 13 | * (c) Copyright 1987, Hewlett-Packard Company. 14 | ** Licensed under the Apache License, Version 2.0 (the "License"); 15 | ** you may not use this file except in compliance with the License. 16 | ** You may obtain a copy of the License at 17 | ** http://www.apache.org/licenses/LICENSE-2.0 18 | ** Unless required by applicable law or agreed to in writing, software 19 | ** distributed under the License is distributed on an "AS IS" BASIS, 20 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | ** See the License for the specific language governing permissions and 22 | ** limitations under the License. 23 | * 24 | *****************************************************************************/ 25 | #ifndef SPLIT_H 26 | #define SPLIT_H 27 | 28 | /*---------------------------------------------------------------------- 29 | I n c l u d e s 30 | ----------------------------------------------------------------------*/ 31 | #include "blobs.h" 32 | #include "oldlist.h" 33 | 34 | /*---------------------------------------------------------------------- 35 | T y p e s 36 | ----------------------------------------------------------------------*/ 37 | typedef struct split_record 38 | { /* SPLIT */ 39 | EDGEPT *point1; 40 | EDGEPT *point2; 41 | } SPLIT; 42 | 43 | typedef LIST SPLITS; /* SPLITS */ 44 | 45 | /*---------------------------------------------------------------------- 46 | V a r i a b l e s 47 | ----------------------------------------------------------------------*/ 48 | 49 | extern BOOL_VAR_H(wordrec_display_splits, 0, "Display splits"); 50 | 51 | /*---------------------------------------------------------------------- 52 | M a c r o s 53 | ----------------------------------------------------------------------*/ 54 | /********************************************************************** 55 | * clone_split 56 | * 57 | * Create a new split record and set the contents equal to the contents 58 | * of this record. 59 | **********************************************************************/ 60 | 61 | #define clone_split(dest,source) \ 62 | if (source) \ 63 | (dest) = new_split ((source)->point1, (source)->point2); \ 64 | else \ 65 | (dest) = (SPLIT*) NULL \ 66 | 67 | 68 | /*---------------------------------------------------------------------- 69 | F u n c t i o n s 70 | ----------------------------------------------------------------------*/ 71 | void delete_split(SPLIT *split); 72 | 73 | EDGEPT *make_edgept(int x, int y, EDGEPT *next, EDGEPT *prev); 74 | 75 | void remove_edgept(EDGEPT *point); 76 | 77 | SPLIT *new_split(EDGEPT *point1, EDGEPT *point2); 78 | 79 | void print_split(SPLIT *split); 80 | 81 | void split_outline(EDGEPT *join_point1, EDGEPT *join_point2); 82 | 83 | void unsplit_outlines(EDGEPT *p1, EDGEPT *p2); 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/sudoku.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef SUDOKU_H_INCLUDED 28 | #define SUDOKU_H_INCLUDED 29 | 30 | /* 31 | * sudoku.h 32 | * 33 | * The L_Sudoku holds all the information of the current state. 34 | * 35 | * The input to sudokuCreate() is a file with any number of lines 36 | * starting with '#', followed by 9 lines consisting of 9 numbers 37 | * in each line. These have the known values and use 0 for the unknowns. 38 | * Blank lines are ignored. 39 | * 40 | * The @locs array holds the indices of the unknowns, numbered 41 | * left-to-right and top-to-bottom from 0 to 80. The array size 42 | * is initialized to @num. @current is the index into the @locs 43 | * array of the current guess: locs[current]. 44 | * 45 | * The @state array is used to determine the validity of each guess. 46 | * It is of size 81, and is initialized by setting the unknowns to 0 47 | * and the knowns to their input values. 48 | */ 49 | struct L_Sudoku 50 | { 51 | l_int32 num; /* number of unknowns */ 52 | l_int32 *locs; /* location of unknowns */ 53 | l_int32 current; /* index into @locs of current location */ 54 | l_int32 *init; /* initial state, with 0 representing */ 55 | /* the unknowns */ 56 | l_int32 *state; /* present state, including inits and */ 57 | /* guesses of unknowns up to @current */ 58 | l_int32 nguess; /* shows current number of guesses */ 59 | l_int32 finished; /* set to 1 when solved */ 60 | l_int32 failure; /* set to 1 if no solution is possible */ 61 | }; 62 | typedef struct L_Sudoku L_SUDOKU; 63 | 64 | 65 | /* For printing out array data */ 66 | enum { 67 | L_SUDOKU_INIT = 0, 68 | L_SUDOKU_STATE = 1 69 | }; 70 | 71 | #endif /* SUDOKU_H_INCLUDED */ 72 | 73 | 74 | -------------------------------------------------------------------------------- /OCR-Example/PhotoChooserViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // OCR-Example 4 | // 5 | // Created by Christopher Constable on 5/10/13. 6 | // Copyright (c) 2013 Christopher Constable. All rights reserved. 7 | // 8 | 9 | #import "PhotoChooserViewController.h" 10 | #import "ResultsViewController.h" 11 | 12 | @interface PhotoChooserViewController () 13 | @property (nonatomic, strong) UIImage *selectedImage; 14 | @end 15 | 16 | @implementation PhotoChooserViewController 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view, typically from a nib. 22 | } 23 | 24 | - (void)didReceiveMemoryWarning 25 | { 26 | [super didReceiveMemoryWarning]; 27 | // Dispose of any resources that can be recreated. 28 | } 29 | 30 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 31 | { 32 | self.selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage]; 33 | 34 | // Show process button 35 | if (self.selectedImage) { 36 | UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"Process" 37 | style:UIBarButtonItemStylePlain 38 | target:self 39 | action:@selector(processWasPressed:)]; 40 | [self.navigationItem setRightBarButtonItem:barButton animated:YES]; 41 | [self.selectedImageView setImage:self.selectedImage]; 42 | } 43 | 44 | [self dismissViewControllerAnimated:YES completion:nil]; 45 | } 46 | 47 | - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker 48 | { 49 | [self dismissViewControllerAnimated:YES completion:nil]; 50 | } 51 | 52 | - (void)processWasPressed:(id)sender 53 | { 54 | ResultsViewController *resultsVC = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"Results"]; 55 | 56 | // Create loading view. 57 | resultsVC.loadingView = [[UIView alloc] initWithFrame:self.view.bounds]; 58 | resultsVC.loadingView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5]; 59 | [resultsVC.view addSubview:resultsVC.loadingView]; 60 | UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] init]; 61 | [resultsVC.loadingView addSubview:activityView]; 62 | activityView.center = resultsVC.loadingView.center; 63 | [activityView startAnimating]; 64 | 65 | resultsVC.selectedImage = self.selectedImage; 66 | [resultsVC.selectedImageView setImage:self.selectedImage]; 67 | 68 | // Push 69 | [self.navigationController pushViewController:resultsVC animated:YES]; 70 | 71 | } 72 | 73 | - (IBAction)choosePhotoWasTapped:(id)sender { 74 | UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; 75 | imagePickerController.delegate = self; 76 | 77 | if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) { 78 | imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 79 | imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto; 80 | } 81 | else { 82 | imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; 83 | } 84 | 85 | [self presentViewController:imagePickerController 86 | animated:YES 87 | completion:nil]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/queue.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef LEPTONICA_QUEUE_H 28 | #define LEPTONICA_QUEUE_H 29 | 30 | /* 31 | * queue.h 32 | * 33 | * Expandable pointer queue for arbitrary void* data. 34 | * 35 | * The L_Queue is a fifo that implements a queue of void* pointers. 36 | * It can be used to hold a queue of any type of struct. 37 | * 38 | * Internally, it maintains two counters: 39 | * nhead: location of head (in ptrs) from the beginning 40 | * of the array. 41 | * nelem: number of ptr elements stored in the queue. 42 | * 43 | * The element at the head of the queue, which is the next to 44 | * be removed, is array[nhead]. The location at the tail of the 45 | * queue to which the next element will be added is 46 | * array[nhead + nelem]. 47 | * 48 | * As items are added to the queue, nelem increases. 49 | * As items are removed, nhead increases and nelem decreases. 50 | * Any time the tail reaches the end of the allocated array, 51 | * all the pointers are shifted to the left, so that the head 52 | * is at the beginning of the array. 53 | * If the array becomes more than 3/4 full, it doubles in size. 54 | * 55 | * The auxiliary stack can be used in a wrapper for re-using 56 | * items popped from the queue. It is not made by default. 57 | * 58 | * For further implementation details, see queue.c. 59 | */ 60 | 61 | struct L_Queue 62 | { 63 | l_int32 nalloc; /* size of allocated ptr array */ 64 | l_int32 nhead; /* location of head (in ptrs) from the */ 65 | /* beginning of the array */ 66 | l_int32 nelem; /* number of elements stored in the queue */ 67 | void **array; /* ptr array */ 68 | struct L_Stack *stack; /* auxiliary stack */ 69 | 70 | }; 71 | typedef struct L_Queue L_QUEUE; 72 | 73 | 74 | #endif /* LEPTONICA_QUEUE_H */ 75 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/watershed.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef LEPTONICA_WATERSHED_H 28 | #define LEPTONICA_WATERSHED_H 29 | 30 | /* 31 | * watershed.h 32 | * 33 | * Simple data structure to hold watershed data. 34 | * All data here is owned by the L_WShed and must be freed. 35 | */ 36 | 37 | struct L_WShed 38 | { 39 | struct Pix *pixs; /* clone of input 8 bpp pixs */ 40 | struct Pix *pixm; /* clone of input 1 bpp seed (marker) pixm */ 41 | l_int32 mindepth; /* minimum depth allowed for a watershed */ 42 | struct Pix *pixlab; /* 16 bpp label pix */ 43 | struct Pix *pixt; /* scratch pix for computing wshed regions */ 44 | void **lines8; /* line ptrs for pixs */ 45 | void **linem1; /* line ptrs for pixm */ 46 | void **linelab32; /* line ptrs for pixlab */ 47 | void **linet1; /* line ptrs for pixt */ 48 | struct Pixa *pixad; /* result: 1 bpp pixa of watersheds */ 49 | struct Pta *ptas; /* pta of initial seed pixels */ 50 | struct Numa *nasi; /* numa of seed indicators; 0 if completed */ 51 | struct Numa *nash; /* numa of initial seed heights */ 52 | struct Numa *namh; /* numa of initial minima heights */ 53 | struct Numa *nalevels; /* result: numa of watershed levels */ 54 | l_int32 nseeds; /* number of seeds (markers) */ 55 | l_int32 nother; /* number of minima different from seeds */ 56 | l_int32 *lut; /* lut for pixel indices */ 57 | struct Numa **links; /* back-links into lut, for updates */ 58 | l_int32 arraysize; /* size of links array */ 59 | l_int32 debug; /* set to 1 for debug output */ 60 | }; 61 | typedef struct L_WShed L_WSHED; 62 | 63 | #endif /* LEPTONICA_WATERSHED_H */ 64 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/unichar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: unichar.h 3 | // Description: Unicode character/ligature class. 4 | // Author: Ray Smith 5 | // Created: Wed Jun 28 17:05:01 PDT 2006 6 | // 7 | // (C) Copyright 2006, Google Inc. 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | /////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef TESSERACT_CCUTIL_UNICHAR_H__ 21 | #define TESSERACT_CCUTIL_UNICHAR_H__ 22 | 23 | #include 24 | #include 25 | 26 | // Maximum number of characters that can be stored in a UNICHAR. Must be 27 | // at least 4. Must not exceed 31 without changing the coding of length. 28 | #define UNICHAR_LEN 30 29 | 30 | // A UNICHAR_ID is the unique id of a unichar. 31 | typedef int UNICHAR_ID; 32 | 33 | // A variable to indicate an invalid or uninitialized unichar id. 34 | static const int INVALID_UNICHAR_ID = -1; 35 | // A special unichar that corresponds to INVALID_UNICHAR_ID. 36 | static const char INVALID_UNICHAR[] = "__INVALID_UNICHAR__"; 37 | 38 | enum StrongScriptDirection { 39 | DIR_NEUTRAL = 0, // Text contains only neutral characters. 40 | DIR_LEFT_TO_RIGHT = 1, // Text contains no Right-to-Left characters. 41 | DIR_RIGHT_TO_LEFT = 2, // Text contains no Left-to-Right characters. 42 | DIR_MIX = 3, // Text contains a mixture of left-to-right 43 | // and right-to-left characters. 44 | }; 45 | 46 | // The UNICHAR class holds a single classification result. This may be 47 | // a single Unicode character (stored as between 1 and 4 utf8 bytes) or 48 | // multple Unicode characters representing the NFKC expansion of a ligature 49 | // such as fi, ffl etc. These are also stored as utf8. 50 | class UNICHAR { 51 | public: 52 | UNICHAR() { 53 | memset(chars, 0, UNICHAR_LEN); 54 | } 55 | 56 | // Construct from a utf8 string. If len<0 then the string is null terminated. 57 | // If the string is too long to fit in the UNICHAR then it takes only what 58 | // will fit. 59 | UNICHAR(const char* utf8_str, int len); 60 | 61 | // Construct from a single UCS4 character. 62 | explicit UNICHAR(int unicode); 63 | 64 | // Default copy constructor and operator= are OK. 65 | 66 | // Get the first character as UCS-4. 67 | int first_uni() const; 68 | 69 | // Get the length of the UTF8 string. 70 | int utf8_len() const { 71 | int len = chars[UNICHAR_LEN - 1]; 72 | return len >=0 && len < UNICHAR_LEN ? len : UNICHAR_LEN; 73 | } 74 | 75 | // Get a UTF8 string, but NOT NULL terminated. 76 | const char* utf8() const { 77 | return chars; 78 | } 79 | 80 | // Get a terminated UTF8 string: Must delete[] it after use. 81 | char* utf8_str() const; 82 | 83 | // Get the number of bytes in the first character of the given utf8 string. 84 | static int utf8_step(const char* utf8_str); 85 | 86 | private: 87 | // A UTF-8 representation of 1 or more Unicode characters. 88 | // The last element (chars[UNICHAR_LEN - 1]) is a length if 89 | // its value < UNICHAR_LEN, otherwise it is a genuine character. 90 | char chars[UNICHAR_LEN]; 91 | }; 92 | 93 | #endif // TESSERACT_CCUTIL_UNICHAR_H__ 94 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/list.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | 28 | #ifndef LEPTONICA_LIST_H 29 | #define LEPTONICA_LIST_H 30 | 31 | /* 32 | * list.h 33 | * 34 | * Cell for double-linked lists 35 | * 36 | * This allows composition of a list of cells with 37 | * prev, next and data pointers. Generic data 38 | * structures hang on the list cell data pointers. 39 | * 40 | * The list is not circular because that would add much 41 | * complexity in traversing the list under general 42 | * conditions where list cells can be added and removed. 43 | * The only disadvantage of not having the head point to 44 | * the last cell is that the list must be traversed to 45 | * find its tail. However, this traversal is fast, and 46 | * the listRemoveFromTail() function updates the tail 47 | * so there is no searching overhead with repeated use. 48 | * 49 | * The list macros are used to run through a list, and their 50 | * use is encouraged. They are invoked, e.g., as 51 | * 52 | * DLLIST *head, *elem; 53 | * ... 54 | * L_BEGIN_LIST_FORWARD(head, elem) 55 | * data > 56 | * L_END_LIST 57 | * 58 | */ 59 | 60 | struct DoubleLinkedList 61 | { 62 | struct DoubleLinkedList *prev; 63 | struct DoubleLinkedList *next; 64 | void *data; 65 | }; 66 | typedef struct DoubleLinkedList DLLIST; 67 | 68 | 69 | /* Simple list traverse macros */ 70 | #define L_BEGIN_LIST_FORWARD(head, element) \ 71 | { \ 72 | DLLIST *_leptvar_nextelem_; \ 73 | for ((element) = (head); (element); (element) = _leptvar_nextelem_) { \ 74 | _leptvar_nextelem_ = (element)->next; 75 | 76 | 77 | #define L_BEGIN_LIST_REVERSE(tail, element) \ 78 | { \ 79 | DLLIST *_leptvar_prevelem_; \ 80 | for ((element) = (tail); (element); (element) = _leptvar_prevelem_) { \ 81 | _leptvar_prevelem_ = (element)->prev; 82 | 83 | 84 | #define L_END_LIST }} 85 | 86 | 87 | #endif /* LEPTONICA_LIST_H */ 88 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/gplot.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef LEPTONICA_GPLOT_H 28 | #define LEPTONICA_GPLOT_H 29 | 30 | /* 31 | * gplot.h 32 | * 33 | * Data structures and parameters for generating gnuplot files 34 | */ 35 | 36 | #define GPLOT_VERSION_NUMBER 1 37 | 38 | #define NUM_GPLOT_STYLES 5 39 | enum GPLOT_STYLE { 40 | GPLOT_LINES = 0, 41 | GPLOT_POINTS = 1, 42 | GPLOT_IMPULSES = 2, 43 | GPLOT_LINESPOINTS = 3, 44 | GPLOT_DOTS = 4 45 | }; 46 | 47 | #define NUM_GPLOT_OUTPUTS 6 48 | enum GPLOT_OUTPUT { 49 | GPLOT_NONE = 0, 50 | GPLOT_PNG = 1, 51 | GPLOT_PS = 2, 52 | GPLOT_EPS = 3, 53 | GPLOT_X11 = 4, 54 | GPLOT_LATEX = 5 55 | }; 56 | 57 | enum GPLOT_SCALING { 58 | GPLOT_LINEAR_SCALE = 0, /* default */ 59 | GPLOT_LOG_SCALE_X = 1, 60 | GPLOT_LOG_SCALE_Y = 2, 61 | GPLOT_LOG_SCALE_X_Y = 3 62 | }; 63 | 64 | extern const char *gplotstylenames[]; /* used in gnuplot cmd file */ 65 | extern const char *gplotfilestyles[]; /* used in simple file input */ 66 | extern const char *gplotfileoutputs[]; /* used in simple file input */ 67 | 68 | struct GPlot 69 | { 70 | char *rootname; /* for cmd, data, output */ 71 | char *cmdname; /* command file name */ 72 | struct Sarray *cmddata; /* command file contents */ 73 | struct Sarray *datanames; /* data file names */ 74 | struct Sarray *plotdata; /* plot data (1 string/file) */ 75 | struct Sarray *plottitles; /* title for each individual plot */ 76 | struct Numa *plotstyles; /* plot style for individual plots */ 77 | l_int32 nplots; /* current number of plots */ 78 | char *outname; /* output file name */ 79 | l_int32 outformat; /* GPLOT_OUTPUT values */ 80 | l_int32 scaling; /* GPLOT_SCALING values */ 81 | char *title; /* optional */ 82 | char *xlabel; /* optional x axis label */ 83 | char *ylabel; /* optional y axis label */ 84 | }; 85 | typedef struct GPlot GPLOT; 86 | 87 | 88 | #endif /* LEPTONICA_GPLOT_H */ 89 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/quspline.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: quspline.h (Formerly qspline.h) 3 | * Description: Code for the QSPLINE class. 4 | * Author: Ray Smith 5 | * Created: Tue Oct 08 17:16:12 BST 1991 6 | * 7 | * (C) Copyright 1991, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef QUSPLINE_H 21 | #define QUSPLINE_H 22 | 23 | #include "quadratc.h" 24 | #include "serialis.h" 25 | #include "memry.h" 26 | #include "rect.h" 27 | 28 | class ROW; 29 | 30 | class QSPLINE 31 | { 32 | friend void make_first_baseline(TBOX *, 33 | int, 34 | int *, 35 | int *, 36 | QSPLINE *, 37 | QSPLINE *, 38 | float); 39 | friend void make_holed_baseline(TBOX *, int, QSPLINE *, QSPLINE *, float); 40 | friend void tweak_row_baseline(ROW *, double, double); 41 | public: 42 | QSPLINE() { //empty constructor 43 | segments = 0; 44 | xcoords = NULL; //everything empty 45 | quadratics = NULL; 46 | } 47 | QSPLINE( //copy constructor 48 | const QSPLINE &src); 49 | QSPLINE( //constructor 50 | inT32 count, //number of segments 51 | inT32 *xstarts, //segment starts 52 | double *coeffs); //coefficients 53 | ~QSPLINE (); //destructor 54 | QSPLINE ( //least squares fit 55 | int xstarts[], //spline boundaries 56 | int segcount, //no of segments 57 | int xcoords[], //points to fit 58 | int ycoords[], int blobcount,//no of coords 59 | int degree); //function 60 | 61 | double step( //step change 62 | double x1, //between coords 63 | double x2); 64 | double y( //evaluate 65 | double x) const; //at x 66 | 67 | void move( // reposition spline 68 | ICOORD vec); // by vector 69 | BOOL8 overlap( //test overlap 70 | QSPLINE *spline2, //2 cannot be smaller 71 | double fraction); //by more than this 72 | void extrapolate( //linear extrapolation 73 | double gradient, //gradient to use 74 | int left, //new left edge 75 | int right); //new right edge 76 | 77 | #ifndef GRAPHICS_DISABLED 78 | void plot( //draw it 79 | ScrollView* window, //in window 80 | ScrollView::Color colour) const; //in colour 81 | #endif 82 | 83 | QSPLINE & operator= ( 84 | const QSPLINE & source); //from this 85 | 86 | private: 87 | 88 | inT32 spline_index( //binary search 89 | double x) const; //for x 90 | inT32 segments; //no of segments 91 | inT32 *xcoords; //no of coords 92 | QUAD_COEFFS *quadratics; //spline pieces 93 | }; 94 | #endif 95 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/pgedit.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: pgedit.h 3 | // Description: Page structure file editor 4 | // Author: Joern Wanke 5 | // Created: Wed Jul 18 10:05:01 PDT 2007 6 | // 7 | // (C) Copyright 2007, Google Inc. 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | /////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef PGEDIT_H 21 | #define PGEDIT_H 22 | 23 | #include "ocrblock.h" 24 | #include "ocrrow.h" 25 | #include "werd.h" 26 | #include "rect.h" 27 | #include "params.h" 28 | #include "notdll.h" 29 | #include "tesseractclass.h" 30 | 31 | class ScrollView; 32 | class SVMenuNode; 33 | struct SVEvent; 34 | 35 | // A small event handler class to process incoming events to 36 | // this window. 37 | class PGEventHandler : public SVEventHandler { 38 | public: 39 | PGEventHandler(tesseract::Tesseract* tess) : tess_(tess) { 40 | } 41 | void Notify(const SVEvent* sve); 42 | private: 43 | tesseract::Tesseract* tess_; 44 | }; 45 | 46 | extern BLOCK_LIST *current_block_list; 47 | extern STRING_VAR_H (editor_image_win_name, "EditorImage", 48 | "Editor image window name"); 49 | extern INT_VAR_H (editor_image_xpos, 590, "Editor image X Pos"); 50 | extern INT_VAR_H (editor_image_ypos, 10, "Editor image Y Pos"); 51 | extern INT_VAR_H (editor_image_height, 680, "Editor image height"); 52 | extern INT_VAR_H (editor_image_width, 655, "Editor image width"); 53 | extern INT_VAR_H (editor_image_word_bb_color, BLUE, 54 | "Word bounding box colour"); 55 | extern INT_VAR_H (editor_image_blob_bb_color, YELLOW, 56 | "Blob bounding box colour"); 57 | extern INT_VAR_H (editor_image_text_color, WHITE, "Correct text colour"); 58 | extern STRING_VAR_H (editor_dbwin_name, "EditorDBWin", 59 | "Editor debug window name"); 60 | extern INT_VAR_H (editor_dbwin_xpos, 50, "Editor debug window X Pos"); 61 | extern INT_VAR_H (editor_dbwin_ypos, 500, "Editor debug window Y Pos"); 62 | extern INT_VAR_H (editor_dbwin_height, 24, "Editor debug window height"); 63 | extern INT_VAR_H (editor_dbwin_width, 80, "Editor debug window width"); 64 | extern STRING_VAR_H (editor_word_name, "BlnWords", 65 | "BL normalised word window"); 66 | extern INT_VAR_H (editor_word_xpos, 60, "Word window X Pos"); 67 | extern INT_VAR_H (editor_word_ypos, 510, "Word window Y Pos"); 68 | extern INT_VAR_H (editor_word_height, 240, "Word window height"); 69 | extern INT_VAR_H (editor_word_width, 655, "Word window width"); 70 | extern double_VAR_H (editor_smd_scale_factor, 1.0, "Scaling for smd image"); 71 | 72 | ScrollView* bln_word_window_handle(); //return handle 73 | void build_image_window(int width, int height); 74 | void display_bln_lines(ScrollView window, 75 | ScrollView::Color colour, 76 | float scale_factor, 77 | float y_offset, 78 | float minx, 79 | float maxx); 80 | //function to call 81 | void pgeditor_msg( //message display 82 | const char *msg); 83 | void pgeditor_show_point( //display coords 84 | SVEvent *event); 85 | //put bln word in box 86 | void show_point(PAGE_RES* page_res, float x, float y); 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/errcode.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: errcode.h (Formerly error.h) 3 | * Description: Header file for generic error handler class 4 | * Author: Ray Smith 5 | * Created: Tue May 1 16:23:36 BST 1990 6 | * 7 | * (C) Copyright 1990, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef ERRCODE_H 21 | #define ERRCODE_H 22 | 23 | #include "host.h" 24 | 25 | /*Control parameters for error()*/ 26 | enum TessErrorLogCode { 27 | DBG = -1, /*log without alert */ 28 | TESSLOG = 0, /*alert user */ 29 | TESSEXIT = 1, /*exit after erro */ 30 | ABORT = 2 /*abort after error */ 31 | }; 32 | 33 | /* Explicit Error Abort codes */ 34 | #define NO_ABORT_CODE 0 35 | #define LIST_ABORT 1 36 | #define MEMORY_ABORT 2 37 | #define FILE_ABORT 3 38 | 39 | /* Location of code at error codes Reserve 0..2 (status codes 0..23 for UNLV)*/ 40 | #define LOC_UNUSED0 0 41 | #define LOC_UNUSED1 1 42 | #define LOC_UNUSED2 2 43 | #define LOC_INIT 3 44 | #define LOC_EDGE_PROG 4 45 | #define LOC_TEXT_ORD_ROWS 5 46 | #define LOC_TEXT_ORD_WORDS 6 47 | #define LOC_PASS1 7 48 | #define LOC_PASS2 8 49 | /* Reserve up to 8..13 for adding subloc 0/3 plus subsubloc 0/1/2 */ 50 | #define LOC_FUZZY_SPACE 14 51 | /* Reserve up to 14..20 for adding subloc 0/3 plus subsubloc 0/1/2 */ 52 | #define LOC_MM_ADAPT 21 53 | #define LOC_DOC_BLK_REJ 22 54 | #define LOC_WRITE_RESULTS 23 55 | #define LOC_ADAPTIVE 24 56 | /* DONT DEFINE ANY LOCATION > 31 !!! */ 57 | 58 | /* Sub locatation determines whether pass2 was in normal mode or fix xht mode*/ 59 | #define SUBLOC_NORM 0 60 | #define SUBLOC_FIX_XHT 3 61 | 62 | /* Sub Sub locatation determines whether match_word_pass2 was in Tess 63 | matcher, NN matcher or somewhere else */ 64 | 65 | #define SUBSUBLOC_OTHER 0 66 | #define SUBSUBLOC_TESS 1 67 | #define SUBSUBLOC_NN 2 68 | 69 | class TESS_API ERRCODE { // error handler class 70 | const char *message; // error message 71 | public: 72 | void error( // error print function 73 | const char *caller, // function location 74 | TessErrorLogCode action, // action to take 75 | const char *format, ... // fprintf format 76 | ) const; 77 | ERRCODE(const char *string) { 78 | message = string; 79 | } // initialize with string 80 | }; 81 | 82 | const ERRCODE ASSERT_FAILED = "Assert failed"; 83 | 84 | #define ASSERT_HOST(x) if (!(x)) \ 85 | { \ 86 | ASSERT_FAILED.error(#x,ABORT,"in file %s, line %d", \ 87 | __FILE__,__LINE__); \ 88 | } 89 | 90 | void signal_exit( // 91 | int signal_code //Signal which 92 | ); 93 | extern "C" 94 | { 95 | void err_exit(); 96 | //The real signal 97 | void signal_termination_handler(int sig); 98 | }; 99 | 100 | void set_global_loc_code(int loc_code); 101 | 102 | void set_global_subloc_code(int loc_code); 103 | 104 | void set_global_subsubloc_code(int loc_code); 105 | #endif 106 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/ptra.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef LEPTONICA_PTRA_H 28 | #define LEPTONICA_PTRA_H 29 | 30 | /* 31 | * Contains the following structs: 32 | * struct L_Ptra 33 | * struct L_Ptraa 34 | * 35 | * Contains definitions for: 36 | * L_Ptra compaction flags for removal 37 | * L_Ptra shifting flags for insert 38 | * L_Ptraa accessor flags 39 | */ 40 | 41 | 42 | /*------------------------------------------------------------------------* 43 | * Generic Ptr Array Structs * 44 | *------------------------------------------------------------------------*/ 45 | 46 | /* Generic pointer array */ 47 | struct L_Ptra 48 | { 49 | l_int32 nalloc; /* size of allocated ptr array */ 50 | l_int32 imax; /* greatest valid index */ 51 | l_int32 nactual; /* actual number of stored elements */ 52 | void **array; /* ptr array */ 53 | }; 54 | typedef struct L_Ptra L_PTRA; 55 | 56 | 57 | /* Array of generic pointer arrays */ 58 | struct L_Ptraa 59 | { 60 | l_int32 nalloc; /* size of allocated ptr array */ 61 | struct L_Ptra **ptra; /* array of ptra */ 62 | }; 63 | typedef struct L_Ptraa L_PTRAA; 64 | 65 | 66 | 67 | /*------------------------------------------------------------------------* 68 | * Array flags * 69 | *------------------------------------------------------------------------*/ 70 | 71 | /* Flags for removal from L_Ptra */ 72 | enum { 73 | L_NO_COMPACTION = 1, /* null the pointer only */ 74 | L_COMPACTION = 2 /* compact the array */ 75 | }; 76 | 77 | /* Flags for insertion into L_Ptra */ 78 | enum { 79 | L_AUTO_DOWNSHIFT = 0, /* choose based on number of holes */ 80 | L_MIN_DOWNSHIFT = 1, /* downshifts min # of ptrs below insert */ 81 | L_FULL_DOWNSHIFT = 2 /* downshifts all ptrs below insert */ 82 | }; 83 | 84 | /* Accessor flags for L_Ptraa */ 85 | enum { 86 | L_HANDLE_ONLY = 0, /* ptr to L_Ptra; caller can inspect only */ 87 | L_REMOVE = 1 /* caller owns; destroy or save in L_Ptraa */ 88 | }; 89 | 90 | 91 | #endif /* LEPTONICA_PTRA_H */ 92 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/polyblk.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: polyblk.h (Formerly poly_block.h) 3 | * Description: Polygonal blocks 4 | * Author: Sheelagh Lloyd? 5 | * Created: 6 | * 7 | * (C) Copyright 1993, Hewlett-Packard Ltd. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | #ifndef POLYBLK_H 20 | #define POLYBLK_H 21 | 22 | #include "publictypes.h" 23 | #include "elst.h" 24 | #include "points.h" 25 | #include "rect.h" 26 | #include "scrollview.h" 27 | 28 | #include "hpddef.h" // must be last (handpd.dll) 29 | 30 | class DLLSYM POLY_BLOCK { 31 | public: 32 | POLY_BLOCK() { 33 | } 34 | // Initialize from box coordinates. 35 | POLY_BLOCK(const TBOX& box, PolyBlockType type); 36 | POLY_BLOCK(ICOORDELT_LIST *points, PolyBlockType type); 37 | ~POLY_BLOCK () { 38 | } 39 | 40 | TBOX *bounding_box() { // access function 41 | return &box; 42 | } 43 | 44 | ICOORDELT_LIST *points() { // access function 45 | return &vertices; 46 | } 47 | 48 | void compute_bb(); 49 | 50 | PolyBlockType isA() const { 51 | return type; 52 | } 53 | 54 | bool IsText() const { 55 | return PTIsTextType(type); 56 | } 57 | 58 | // Rotate about the origin by the given rotation. (Analogous to 59 | // multiplying by a complex number. 60 | void rotate(FCOORD rotation); 61 | // Reflect the coords of the polygon in the y-axis. (Flip the sign of x.) 62 | void reflect_in_y_axis(); 63 | // Move by adding shift to all coordinates. 64 | void move(ICOORD shift); 65 | 66 | void plot(ScrollView* window, inT32 num); 67 | 68 | #ifndef GRAPHICS_DISABLED 69 | void fill(ScrollView* window, ScrollView::Color colour); 70 | #endif // GRAPHICS_DISABLED 71 | 72 | // Returns true if other is inside this. 73 | bool contains(POLY_BLOCK *other); 74 | 75 | // Returns true if the polygons of other and this overlap. 76 | bool overlap(POLY_BLOCK *other); 77 | 78 | // Returns the winding number of this around the test_pt. 79 | // Positive for anticlockwise, negative for clockwise, and zero for 80 | // test_pt outside this. 81 | inT16 winding_number(const ICOORD &test_pt); 82 | 83 | #ifndef GRAPHICS_DISABLED 84 | // Static utility functions to handle the PolyBlockType. 85 | // Returns a color to draw the given type. 86 | static ScrollView::Color ColorForPolyBlockType(PolyBlockType type); 87 | #endif // GRAPHICS_DISABLED 88 | 89 | private: 90 | ICOORDELT_LIST vertices; // vertices 91 | TBOX box; // bounding box 92 | PolyBlockType type; // Type of this region. 93 | }; 94 | 95 | // Class to iterate the scanlines of a polygon. 96 | class DLLSYM PB_LINE_IT { 97 | public: 98 | PB_LINE_IT(POLY_BLOCK *blkptr) { 99 | block = blkptr; 100 | } 101 | 102 | void set_to_block(POLY_BLOCK * blkptr) { 103 | block = blkptr; 104 | } 105 | 106 | // Returns a list of runs of pixels for the given y coord. 107 | // Each element of the returned list is the start (x) and extent(y) of 108 | // a run inside the region. 109 | // Delete the returned list after use. 110 | ICOORDELT_LIST *get_line(inT16 y); 111 | 112 | private: 113 | POLY_BLOCK * block; 114 | }; 115 | #endif 116 | -------------------------------------------------------------------------------- /OCR-Example/ImageProcessing.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageWrapper.h 3 | // OCR-Example 4 | // 5 | // Pulled from: http://stackoverflow.com/questions/11624694/what-is-the-ideal-image-for-tesseract-library 6 | 7 | #import 8 | #include 9 | 10 | class Image; 11 | // objective C wrapper for our image class 12 | @interface ImageWrapper : NSObject { 13 | Image *image; 14 | bool ownsImage; 15 | } 16 | 17 | @property(assign, nonatomic) Image *image; 18 | @property(assign, nonatomic) bool ownsImage; 19 | + (ImageWrapper *) imageWithCPPImage:(Image *) theImage; 20 | 21 | @end 22 | 23 | class ImagePoint { 24 | public: 25 | short x,y; 26 | inline ImagePoint(short xpos, short ypos) { 27 | x=xpos; 28 | y=ypos; 29 | } 30 | inline ImagePoint(int xpos, int ypos) { 31 | x=xpos; 32 | y=ypos; 33 | } 34 | inline ImagePoint(const ImagePoint &other) { 35 | x=other.x; 36 | y=other.y; 37 | } 38 | inline ImagePoint() { 39 | x=0; y=0; 40 | } 41 | }; 42 | 43 | class Image { 44 | private: 45 | uint8_t *m_imageData; 46 | uint8_t **m_yptrs; 47 | int m_width; 48 | int m_height; 49 | bool m_ownsData; 50 | Image(ImageWrapper *other, int x1, int y1, int x2, int y2); 51 | Image(int width, int height); 52 | Image(uint8_t *imageData, int width, int height, bool ownsData=false); 53 | Image(UIImage *srcImage, int width, int height, CGInterpolationQuality interpolation, bool imageIsRotatedBy90degrees=false); 54 | void initYptrs(); 55 | public: 56 | // copy a section of another image 57 | static ImageWrapper *createImage(ImageWrapper *other, int x1, int y1, int x2, int y2); 58 | // create an empty image of the required width and height 59 | static ImageWrapper *createImage(int width, int height); 60 | // create an image from data 61 | static ImageWrapper *createImage(uint8_t *imageData, int width, int height, bool ownsData=false); 62 | // take a source UIImage and convert it to greyscale 63 | static ImageWrapper *createImage(UIImage *srcImage, int width, int height, bool imageIsRotatedBy90degrees=false); 64 | // edge detection 65 | ImageWrapper *cannyEdgeExtract(float tlow, float thigh); 66 | // local thresholding 67 | ImageWrapper* autoLocalThreshold(); 68 | // threshold using integral 69 | ImageWrapper *autoIntegratingThreshold(); 70 | // threshold an image automatically 71 | ImageWrapper *autoThreshold(); 72 | // gaussian smooth the image 73 | ImageWrapper *gaussianBlur(); 74 | // get the percent set pixels 75 | int getPercentSet(); 76 | // exrtact a connected area from the image 77 | void extractConnectedRegion(int x, int y, std::vector *points); 78 | // find the largest connected region in the image 79 | void findLargestStructure(std::vector *maxPoints); 80 | // normalise an image 81 | void normalise(); 82 | // rotate by 90, 180, 270, 360 83 | ImageWrapper *rotate(int angle); 84 | // shrink to a new size 85 | ImageWrapper *resize(int newX, int newY); 86 | ImageWrapper *shrinkBy2(); 87 | // histogram equalisation 88 | void HistogramEqualisation(); 89 | // skeltonize 90 | void skeletonise(); 91 | // convert back to a UIImage for display 92 | UIImage *toUIImage(); 93 | ~Image() { 94 | if(m_ownsData) 95 | free(m_imageData); 96 | delete m_yptrs; 97 | } 98 | inline uint8_t* operator[](const int rowIndex) { 99 | return m_yptrs[rowIndex]; 100 | } 101 | inline int getWidth() { 102 | return m_width; 103 | } 104 | inline int getHeight() { 105 | return m_height; 106 | } 107 | }; 108 | 109 | inline bool sortByX1(const ImagePoint &p1, const ImagePoint &p2) { 110 | if(p1.x==p2.x) return p1.y 27 | #include 28 | #include "host.h" 29 | 30 | namespace tesseract { 31 | 32 | // Trivial class to encapsulate a fixed-length array of bits, with 33 | // Serialize/DeSerialize. Replaces the old macros. 34 | class BitVector { 35 | public: 36 | BitVector(); 37 | // Initializes the array to length * false. 38 | explicit BitVector(int length); 39 | BitVector(const BitVector& src); 40 | BitVector& operator=(const BitVector& src); 41 | ~BitVector(); 42 | 43 | // Initializes the array to length * false. 44 | void Init(int length); 45 | 46 | // Returns the number of bits that are accessible in the vector. 47 | int size() const { 48 | return bit_size_; 49 | } 50 | 51 | // Writes to the given file. Returns false in case of error. 52 | bool Serialize(FILE* fp) const; 53 | // Reads from the given file. Returns false in case of error. 54 | // If swap is true, assumes a big/little-endian swap is needed. 55 | bool DeSerialize(bool swap, FILE* fp); 56 | 57 | void SetAllFalse(); 58 | void SetAllTrue(); 59 | 60 | // Accessors to set/reset/get bits. 61 | // The range of index is [0, size()-1]. 62 | // There is debug-only bounds checking. 63 | void SetBit(int index) { 64 | array_[WordIndex(index)] |= BitMask(index); 65 | } 66 | void ResetBit(int index) { 67 | array_[WordIndex(index)] &= ~BitMask(index); 68 | } 69 | void SetValue(int index, bool value) { 70 | if (value) 71 | SetBit(index); 72 | else 73 | ResetBit(index); 74 | } 75 | bool At(int index) const { 76 | return (array_[WordIndex(index)] & BitMask(index)) != 0; 77 | } 78 | bool operator[](int index) const { 79 | return (array_[WordIndex(index)] & BitMask(index)) != 0; 80 | } 81 | 82 | private: 83 | // Allocates memory for a vector of the given length. 84 | void Alloc(int length); 85 | 86 | // Computes the index to array_ for the given index, with debug range 87 | // checking. 88 | int WordIndex(int index) const { 89 | assert(0 <= index && index < bit_size_); 90 | return index / kBitFactor; 91 | } 92 | // Returns a mask to select the appropriate bit for the given index. 93 | uinT32 BitMask(int index) const { 94 | return 1 << (index & (kBitFactor - 1)); 95 | } 96 | // Returns the number of array elements needed to represent the current 97 | // bit_size_. 98 | int WordLength() const { 99 | return (bit_size_ + kBitFactor - 1) / kBitFactor; 100 | } 101 | // Returns the number of bytes consumed by the array_. 102 | int ByteLength() const { 103 | return WordLength() * sizeof(*array_); 104 | } 105 | 106 | // Number of bits in this BitVector. 107 | uinT32 bit_size_; 108 | // Array of words used to pack the bits. 109 | uinT32* array_; 110 | // Number of bits in an array_ element. 111 | static const int kBitFactor = sizeof(uinT32) * 8; 112 | }; 113 | 114 | } // namespace tesseract. 115 | 116 | #endif // TESSERACT_CCUTIL_BITVECTOR_H__ 117 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/dppoint.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: dppoint.h 3 | * Description: Simple generic dynamic programming class. 4 | * Author: Ray Smith 5 | * Created: Wed Mar 25 18:57:01 PDT 2009 6 | * 7 | * (C) Copyright 2009, Google Inc. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | #ifndef TESSERACT_CCSTRUCT_DPPOINT_H__ 21 | #define TESSERACT_CCSTRUCT_DPPOINT_H__ 22 | 23 | #include "host.h" 24 | 25 | namespace tesseract { 26 | 27 | // A simple class to provide a dynamic programming solution to a class of 28 | // 1st-order problems in which the cost is dependent only on the current 29 | // step and the best cost to that step, with a possible special case 30 | // of using the variance of the steps, and only the top choice is required. 31 | // Useful for problems such as finding the optimal cut points in a fixed-pitch 32 | // (vertical or horizontal) situation. 33 | // Skeletal Example: 34 | // DPPoint* array = new DPPoint[width]; 35 | // for (int i = 0; i < width; i++) { 36 | // array[i].AddLocalCost(cost_at_i) 37 | // } 38 | // DPPoint* best_end = DPPoint::Solve(..., array); 39 | // while (best_end != NULL) { 40 | // int cut_index = best_end - array; 41 | // best_end = best_end->best_prev(); 42 | // } 43 | // delete [] array; 44 | class DPPoint { 45 | public: 46 | // The cost function evaluates the total cost at this (excluding this's 47 | // local_cost) and if it beats this's total_cost, then 48 | // replace the appropriate values in this. 49 | typedef inT64 (DPPoint::*CostFunc)(const DPPoint* prev); 50 | 51 | DPPoint() 52 | : local_cost_(0), total_cost_(MAX_INT32), total_steps_(1), best_prev_(NULL), 53 | n_(0), sig_x_(0), sig_xsq_(0) { 54 | } 55 | 56 | // Solve the dynamic programming problem for the given array of points, with 57 | // the given size and cost function. 58 | // Steps backwards are limited to being between min_step and max_step 59 | // inclusive. 60 | // The return value is the tail of the best path. 61 | static DPPoint* Solve(int min_step, int max_step, bool debug, 62 | CostFunc cost_func, int size, DPPoint* points); 63 | 64 | // A CostFunc that takes the variance of step into account in the cost. 65 | inT64 CostWithVariance(const DPPoint* prev); 66 | 67 | // Accessors. 68 | int total_cost() const { 69 | return total_cost_; 70 | } 71 | int Pathlength() const { 72 | return total_steps_; 73 | } 74 | const DPPoint* best_prev() const { 75 | return best_prev_; 76 | } 77 | void AddLocalCost(int new_cost) { 78 | local_cost_ += new_cost; 79 | } 80 | 81 | private: 82 | // Code common to different cost functions. 83 | 84 | // Update the other members if the cost is lower. 85 | void UpdateIfBetter(inT64 cost, inT32 steps, const DPPoint* prev, 86 | inT32 n, inT32 sig_x, inT64 sig_xsq); 87 | 88 | inT32 local_cost_; // Cost of this point on its own. 89 | inT32 total_cost_; // Sum of all costs in best path to here. 90 | // During cost calculations local_cost is excluded. 91 | inT32 total_steps_; // Number of steps in best path to here. 92 | const DPPoint* best_prev_; // Pointer to prev point in best path from here. 93 | // Information for computing the variance part of the cost. 94 | inT32 n_; // Number of steps in best path to here for variance. 95 | inT32 sig_x_; // Sum of step sizes for computing variance. 96 | inT64 sig_xsq_; // Sum of squares of steps for computing variance. 97 | }; 98 | 99 | } // namespace tesseract. 100 | 101 | #endif // TESSERACT_CCSTRUCT_DPPOINT_H__ 102 | 103 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/sorthelper.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: sorthelper.h 3 | // Description: Generic sort and maxfinding class. 4 | // Author: Ray Smith 5 | // Created: Thu May 20 17:48:21 PDT 2010 6 | // 7 | // (C) Copyright 2010, Google Inc. 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | /////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef TESSERACT_CCUTIL_SORTHELPER_H_ 21 | #define TESSERACT_CCUTIL_SORTHELPER_H_ 22 | 23 | #include 24 | #include "genericvector.h" 25 | 26 | // Generic class to provide functions based on a pair. 27 | // T is the value type. 28 | // The class keeps a count of each value and can return the most frequent 29 | // value or a sorted array of the values with counts. 30 | // Note that this class uses linear search for adding. It is better 31 | // to use the STATS class to get the mode of a large number of values 32 | // in a small space. SortHelper is better to get the mode of a small number 33 | // of values from a large space. 34 | // T must have a copy constructor. 35 | template 36 | class SortHelper { 37 | public: 38 | // Simple pair class to hold the values and counts. 39 | template struct SortPair { 40 | PairT value; 41 | int count; 42 | }; 43 | // qsort function to sort by decreasing count. 44 | static int SortPairsByCount(const void* v1, const void* v2) { 45 | const SortPair* p1 = reinterpret_cast*>(v1); 46 | const SortPair* p2 = reinterpret_cast*>(v2); 47 | return p2->count - p1->count; 48 | } 49 | // qsort function to sort by decreasing value. 50 | static int SortPairsByValue(const void* v1, const void* v2) { 51 | const SortPair* p1 = reinterpret_cast*>(v1); 52 | const SortPair* p2 = reinterpret_cast*>(v2); 53 | if (p2->value - p1->value < 0) return -1; 54 | if (p2->value - p1->value > 0) return 1; 55 | return 0; 56 | } 57 | 58 | // Constructor takes a hint of the array size, but it need not be accurate. 59 | explicit SortHelper(int sizehint) : counts_(sizehint) {} 60 | 61 | // Add a value that may be a duplicate of an existing value. 62 | // Uses a linear search. 63 | void Add(T value, int count) { 64 | // Linear search for value. 65 | for (int i = 0; i < counts_.size(); ++i) { 66 | if (counts_[i].value == value) { 67 | counts_[i].count += count; 68 | return; 69 | } 70 | } 71 | SortPair new_pair = {value, count}; 72 | counts_.push_back(SortPair(new_pair)); 73 | } 74 | 75 | // Returns the frequency of the most frequent value. 76 | // If max_value is not NULL, returns the most frequent value. 77 | // If the array is empty, returns -MAX_INT32 and max_value is unchanged. 78 | int MaxCount(T* max_value) const { 79 | int best_count = -MAX_INT32; 80 | for (int i = 0; i < counts_.size(); ++i) { 81 | if (counts_[i].count > best_count) { 82 | best_count = counts_[i].count; 83 | if (max_value != NULL) 84 | *max_value = counts_[i].value; 85 | } 86 | } 87 | return best_count; 88 | } 89 | 90 | // Returns the data array sorted by decreasing frequency. 91 | const GenericVector >& SortByCount() { 92 | counts_.sort(&SortPairsByCount); 93 | return counts_; 94 | } 95 | // Returns the data array sorted by decreasing value. 96 | const GenericVector >& SortByValue() { 97 | counts_.sort(&SortPairsByValue); 98 | return counts_; 99 | } 100 | 101 | private: 102 | GenericVector > counts_; 103 | }; 104 | 105 | 106 | #endif // TESSERACT_CCUTIL_SORTHELPER_H_. 107 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/tesseract_cube_combiner.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * File: tesseract_cube_combiner.h 3 | * Description: Declaration of the Tesseract & Cube results combiner Class 4 | * Author: Ahmad Abdulkader 5 | * Created: 2008 6 | * 7 | * (C) Copyright 2008, Google Inc. 8 | ** Licensed under the Apache License, Version 2.0 (the "License"); 9 | ** you may not use this file except in compliance with the License. 10 | ** You may obtain a copy of the License at 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | * 18 | **********************************************************************/ 19 | 20 | // The TesseractCubeCombiner class provides the functionality of combining 21 | // the recognition results of Tesseract and Cube at the word level 22 | 23 | #ifndef TESSERACT_CCMAIN_TESSERACT_CUBE_COMBINER_H 24 | #define TESSERACT_CCMAIN_TESSERACT_CUBE_COMBINER_H 25 | 26 | #include 27 | #include 28 | #include "pageres.h" 29 | 30 | #ifdef _WIN32 31 | #include 32 | using namespace std; 33 | #endif 34 | 35 | #ifdef USE_STD_NAMESPACE 36 | using std::string; 37 | using std::vector; 38 | #endif 39 | 40 | namespace tesseract { 41 | 42 | class CubeObject; 43 | class NeuralNet; 44 | class CubeRecoContext; 45 | class WordAltList; 46 | 47 | class TesseractCubeCombiner { 48 | public: 49 | explicit TesseractCubeCombiner(CubeRecoContext *cube_cntxt); 50 | virtual ~TesseractCubeCombiner(); 51 | 52 | // There are 2 public methods for combining the results of tesseract 53 | // and cube. Both return the probability that the Tesseract result is 54 | // correct. The difference between the two interfaces is in how the 55 | // passed-in CubeObject is used. 56 | 57 | // The CubeObject parameter is used for 2 purposes: 1) to retrieve 58 | // cube's alt list, and 2) to compute cube's word cost for the 59 | // tesseract result. Both uses may modify the state of the 60 | // CubeObject (including the BeamSearch state) with a call to 61 | // RecognizeWord(). 62 | float CombineResults(WERD_RES *tess_res, CubeObject *cube_obj); 63 | 64 | // The alt_list parameter is expected to have been extracted from the 65 | // CubeObject that recognized the word to be combined. The cube_obj 66 | // parameter passed in is a separate instance to be used only by 67 | // the combiner. 68 | float CombineResults(WERD_RES *tess_res, CubeObject *cube_obj, 69 | WordAltList *alt_list); 70 | 71 | // Public method for computing the combiner features. The agreement 72 | // output parameter will be true if both answers are identical, 73 | // false otherwise. Modifies the cube_alt_list, so no assumptions 74 | // should be made about its state upon return. 75 | bool ComputeCombinerFeatures(const string &tess_res, 76 | int tess_confidence, 77 | CubeObject *cube_obj, 78 | WordAltList *cube_alt_list, 79 | vector *features, 80 | bool *agreement); 81 | 82 | // Is the word valid according to Tesseract's language model 83 | bool ValidWord(const string &str); 84 | 85 | // Loads the combiner neural network from file, using cube_cntxt_ 86 | // to find path. 87 | bool LoadCombinerNet(); 88 | private: 89 | // Normalize a UTF-8 string. Converts the UTF-8 string to UTF32 and optionally 90 | // strips punc and/or normalizes case and then converts back 91 | string NormalizeString(const string &str, bool remove_punc, bool norm_case); 92 | 93 | // Compares 2 strings after optionally normalizing them and or stripping 94 | // punctuation 95 | int CompareStrings(const string &str1, const string &str2, bool ignore_punc, 96 | bool norm_case); 97 | 98 | NeuralNet *combiner_net_; // pointer to the combiner NeuralNet object 99 | CubeRecoContext *cube_cntxt_; // used for language ID and data paths 100 | }; 101 | } 102 | 103 | #endif // TESSERACT_CCMAIN_TESSERACT_CUBE_COMBINER_H 104 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/bmp.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef LEPTONICA_BMP_H 28 | #define LEPTONICA_BMP_H 29 | 30 | /* 31 | * This file is here to describe the fields in the header of 32 | * the BMP file. These fields are not used directly in Leptonica. 33 | * The only thing we use are the sizes of these two headers. 34 | * Furthermore, because of potential namespace conflicts with 35 | * the typedefs and defined sizes, we have changed the names 36 | * to protect anyone who may also need to use the original definitions. 37 | * Thanks to J. D. Bryan for pointing out the potential problems when 38 | * developing on Win32 compatible systems. 39 | */ 40 | 41 | /*-------------------------------------------------------------* 42 | * BMP file header * 43 | *-------------------------------------------------------------*/ 44 | struct BMP_FileHeader 45 | { 46 | l_int16 bfType; /* file type; must be "BM" */ 47 | l_int16 bfSize; /* length of the file; 48 | sizeof(BMP_FileHeader) + 49 | sizeof(BMP_InfoHeader) + 50 | size of color table + 51 | size of DIB bits */ 52 | l_int16 bfFill1; /* remainder of the bfSize field */ 53 | l_int16 bfReserved1; /* don't care (set to 0)*/ 54 | l_int16 bfReserved2; /* don't care (set to 0)*/ 55 | l_int16 bfOffBits; /* offset from beginning of file */ 56 | l_int16 bfFill2; /* remainder of the bfOffBits field */ 57 | }; 58 | typedef struct BMP_FileHeader BMP_FH; 59 | 60 | #define BMP_FHBYTES sizeof(BMP_FH) 61 | 62 | 63 | /*-------------------------------------------------------------* 64 | * BMP info header * 65 | *-------------------------------------------------------------*/ 66 | struct BMP_InfoHeader 67 | { 68 | l_int32 biSize; /* size of the BMP_InfoHeader struct */ 69 | l_int32 biWidth; /* bitmap width in pixels */ 70 | l_int32 biHeight; /* bitmap height in pixels */ 71 | l_int16 biPlanes; /* number of bitmap planes */ 72 | l_int16 biBitCount; /* number of bits per pixel */ 73 | l_int32 biCompression; /* compression format (0 == uncompressed) */ 74 | l_int32 biSizeImage; /* size of image in bytes */ 75 | l_int32 biXPelsPerMeter; /* pixels per meter in x direction */ 76 | l_int32 biYPelsPerMeter; /* pixels per meter in y direction */ 77 | l_int32 biClrUsed; /* number of colors used */ 78 | l_int32 biClrImportant; /* number of important colors used */ 79 | }; 80 | typedef struct BMP_InfoHeader BMP_IH; 81 | 82 | #define BMP_IHBYTES sizeof(BMP_IH) 83 | 84 | 85 | #endif /* LEPTONICA_BMP_H */ 86 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/leptonica/heap.h: -------------------------------------------------------------------------------- 1 | /*====================================================================* 2 | - Copyright (C) 2001 Leptonica. All rights reserved. 3 | - 4 | - Redistribution and use in source and binary forms, with or without 5 | - modification, are permitted provided that the following conditions 6 | - are met: 7 | - 1. Redistributions of source code must retain the above copyright 8 | - notice, this list of conditions and the following disclaimer. 9 | - 2. Redistributions in binary form must reproduce the above 10 | - copyright notice, this list of conditions and the following 11 | - disclaimer in the documentation and/or other materials 12 | - provided with the distribution. 13 | - 14 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY 18 | - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *====================================================================*/ 26 | 27 | #ifndef LEPTONICA_HEAP_H 28 | #define LEPTONICA_HEAP_H 29 | 30 | /* 31 | * heap.h 32 | * 33 | * Expandable priority queue configured as a heap for arbitrary void* data 34 | * 35 | * The L_Heap is used to implement a priority queue. The elements 36 | * in the heap are ordered in either increasing or decreasing key value. 37 | * The key is a float field 'keyval' that is required to be 38 | * contained in the elements of the queue. 39 | * 40 | * The heap is a simple binary tree with the following constraints: 41 | * - the key of each node is >= the keys of the two children 42 | * - the tree is complete, meaning that each level (1, 2, 4, ...) 43 | * is filled and the last level is filled from left to right 44 | * 45 | * The tree structure is implicit in the queue array, with the 46 | * array elements numbered as a breadth-first search of the tree 47 | * from left to right. It is thus guaranteed that the largest 48 | * (or smallest) key belongs to the first element in the array. 49 | * 50 | * Heap sort is used to sort the array. Once an array has been 51 | * sorted as a heap, it is convenient to use it as a priority queue, 52 | * because the min (or max) elements are always at the root of 53 | * the tree (element 0), and once removed, the heap can be 54 | * resorted in not more than log[n] steps, where n is the number 55 | * of elements on the heap. Likewise, if an arbitrary element is 56 | * added to the end of the array A, the sorted heap can be restored 57 | * in not more than log[n] steps. 58 | * 59 | * A L_Heap differs from a L_Queue in that the elements in the former 60 | * are sorted by a key. Internally, the array is maintained 61 | * as a queue, with a pointer to the end of the array. The 62 | * head of the array always remains at array[0]. The array is 63 | * maintained (sorted) as a heap. When an item is removed from 64 | * the head, the last item takes its place (thus reducing the 65 | * array length by 1), and this is followed by array element 66 | * swaps to restore the heap property. When an item is added, 67 | * it goes at the end of the array, and is swapped up to restore 68 | * the heap. If the ptr array is full, adding another item causes 69 | * the ptr array size to double. 70 | * 71 | * For further implementation details, see heap.c. 72 | */ 73 | 74 | struct L_Heap 75 | { 76 | l_int32 nalloc; /* size of allocated ptr array */ 77 | l_int32 n; /* number of elements stored in the heap */ 78 | void **array; /* ptr array */ 79 | l_int32 direction; /* L_SORT_INCREASING or L_SORT_DECREASING */ 80 | }; 81 | typedef struct L_Heap L_HEAP; 82 | 83 | 84 | #endif /* LEPTONICA_HEAP_H */ 85 | -------------------------------------------------------------------------------- /External/tesseract-ios-lib/include/tesseract/boxword.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | // File: boxword.h 3 | // Description: Class to represent the bounding boxes of the output. 4 | // Author: Ray Smith 5 | // Created: Tue May 25 14:18:14 PDT 2010 6 | // 7 | // (C) Copyright 2010, Google Inc. 8 | // Licensed under the Apache License, Version 2.0 (the "License"); 9 | // you may not use this file except in compliance with the License. 10 | // You may obtain a copy of the License at 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | /////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef TESSERACT_CSTRUCT_BOXWORD_H__ 21 | #define TESSERACT_CSTRUCT_BOXWORD_H__ 22 | 23 | #include "genericvector.h" 24 | #include "rect.h" 25 | 26 | class BLOCK; 27 | class DENORM; 28 | class PBLOB_LIST; 29 | struct TWERD; 30 | class UNICHARSET; 31 | class WERD; 32 | class WERD_CHOICE; 33 | class WERD_RES; 34 | 35 | namespace tesseract { 36 | 37 | // ScriptPos tells whether a character is subscript, superscript or normal. 38 | enum ScriptPos { 39 | SP_NORMAL, 40 | SP_SUBSCRIPT, 41 | SP_SUPERSCRIPT, 42 | SP_DROPCAP 43 | }; 44 | 45 | // Class to hold an array of bounding boxes for an output word and 46 | // the bounding box of the whole word. 47 | class BoxWord { 48 | public: 49 | BoxWord(); 50 | explicit BoxWord(const BoxWord& src); 51 | ~BoxWord(); 52 | 53 | BoxWord& operator=(const BoxWord& src); 54 | 55 | void CopyFrom(const BoxWord& src); 56 | 57 | // Factory to build a BoxWord from a TWERD and the DENORM to switch 58 | // back to original image coordinates. 59 | // If the denorm is not NULL, then the output is denormalized and rotated 60 | // back to the original image coordinates. 61 | static BoxWord* CopyFromNormalized(const DENORM* denorm, 62 | TWERD* tessword); 63 | 64 | // Sets up the script_pos_ member using the tessword to get the bln 65 | // bounding boxes, the best_choice to get the unichars, and the unicharset 66 | // to get the target positions. If small_caps is true, sub/super are not 67 | // considered, but dropcaps are. 68 | void SetScriptPositions(const UNICHARSET& unicharset, bool small_caps, 69 | TWERD* tessword, WERD_CHOICE* best_choice); 70 | 71 | // Clean up the bounding boxes from the polygonal approximation by 72 | // expanding slightly, then clipping to the blobs from the original_word 73 | // that overlap. If not null, the block provides the inverse rotation. 74 | void ClipToOriginalWord(const BLOCK* block, WERD* original_word); 75 | 76 | // Merges the boxes from start to end, not including end, and deletes 77 | // the boxes between start and end. 78 | void MergeBoxes(int start, int end); 79 | 80 | // Inserts a new box before the given index. 81 | // Recomputes the bounding box. 82 | void InsertBox(int index, const TBOX& box); 83 | 84 | // Deletes the box with the given index, and shuffles up the rest. 85 | // Recomputes the bounding box. 86 | void DeleteBox(int index); 87 | 88 | // Deletes all the boxes stored in BoxWord. 89 | void DeleteAllBoxes(); 90 | 91 | // This and other putatively are the same, so call the (permanent) callback 92 | // for each blob index where the bounding boxes match. 93 | // The callback is deleted on completion. 94 | void ProcessMatchedBlobs(const TWERD& other, TessCallback1* cb) const; 95 | 96 | const TBOX& bounding_box() const { 97 | return bbox_; 98 | } 99 | const int length() const { 100 | return length_; 101 | } 102 | const TBOX& BlobBox(int index) const { 103 | return boxes_[index]; 104 | } 105 | ScriptPos BlobPosition(int index) const { 106 | if (index < 0 || index >= script_pos_.size()) 107 | return SP_NORMAL; 108 | return script_pos_[index]; 109 | } 110 | 111 | private: 112 | void ComputeBoundingBox(); 113 | 114 | TBOX bbox_; 115 | int length_; 116 | GenericVector boxes_; 117 | GenericVector script_pos_; 118 | }; 119 | 120 | } // namespace tesseract. 121 | 122 | 123 | #endif // TESSERACT_CSTRUCT_BOXWORD_H__ 124 | --------------------------------------------------------------------------------