Skip to content

Commit

Permalink
Merge 1667960 into 074604e
Browse files Browse the repository at this point in the history
  • Loading branch information
ws233 committed Aug 26, 2015
2 parents 074604e + 1667960 commit 2a5f817
Show file tree
Hide file tree
Showing 304 changed files with 8,018 additions and 46,333 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@ crashlytics-build.properties
leptonica-*
tesseract-*

TesseractOCR/lib
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ xcode_scheme:
- Template Framework Project
- TestsProject
before_install:
sudo pip install PyYAML; sudo pip install cpp-coveralls
sudo pip install PyYAML; sudo pip install cpp-coveralls; cd TesseractOCR; make; cd ..
after_success:
./scripts/coveralls.rb --extension m --extension mm --exclude-folder include --exclude-folder TestsProject

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ These are the current versions of the upstream bundled libraries within the fram

* Tesseract 3.03-rc1 ([homepage](https://code.google.com/p/tesseract-ocr/))
* Leptonica 1.72 ([homepage](http://leptonica.org/))
* Libtiff 4.0.4 ([homepage](http://www.remotesensing.org/libtiff/))
* Libpng 1.6.17 ([homepage](http://www.libpng.org/pub/png/libpng.html))
* Libjpeg 9a ([homepage](http://libjpeg.sourceforge.net/))
* Image libraries (Thx to ashtons and his [libtiff-ios] (https://github.com/ashtons/libtiff-ios) port):
- Libtiff 4.0.4 ([homepage](http://www.remotesensing.org/libtiff/))
- Libpng 1.6.18 ([homepage](http://www.libpng.org/pub/png/libpng.html))
- Libjpeg 9a ([homepage](http://libjpeg.sourceforge.net/))

Getting Started
=================
Expand Down
1,605 changes: 323 additions & 1,282 deletions Tesseract OCR iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

218 changes: 218 additions & 0 deletions TesseractOCR/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
LEPTON_NAME = leptonica-1.72
PNG_NAME = libpng-1.6.18
JPEG_NAME = jpeg-9a
TIFF_NAME = tiff-4.0.4

SDK_IPHONEOS_PATH=$(shell xcrun --sdk iphoneos --show-sdk-path)
SDK_IPHONESIMULATOR_PATH=$(shell xcrun --sdk iphonesimulator --show-sdk-path)
XCODE_DEVELOPER_PATH=/Applications/Xcode.app/Contents/Developer
XCODETOOLCHAIN_PATH=$(XCODE_DEVELOPER_PATH)/Toolchains/XcodeDefault.xctoolchain
IOS_DEPLOY_TGT="7.0"

TESSERACT_SRC = $(shell pwd)/tesseract-ocr
LEPTON_SRC = $(shell pwd)/$(LEPTON_NAME)
IMAGE_SRC = $(shell pwd)/libtiff-ios
PNG_SRC = $(IMAGE_SRC)/$(PNG_NAME)
JPEG_SRC = $(IMAGE_SRC)/$(JPEG_NAME)
TIFF_SRC = $(IMAGE_SRC)/$(TIFF_NAME)

IMAGE_LIB_DIR = $(IMAGE_SRC)/dependencies/lib/
IMAGE_INC_DIR = $(IMAGE_SRC)/dependencies/include/
INCLUDE_DIR = $(shell pwd)/include
LEPT_INC_DIR = $(INCLUDE_DIR)
TESS_INC_DIR = $(INCLUDE_DIR)
LIB_FAT_DIR = $(shell pwd)/lib

libtessfiles = libtesseract.a
libleptfiles = liblept.a
libpngfiles = libpng.a
libjpegfiles = libjpeg.a
libtifffiles = libtiff.a

sdks = $(SDK_IPHONEOS_PATH) $(SDK_IPHONEOS_PATH) $(SDK_IPHONEOS_PATH) $(SDK_IPHONESIMULATOR_PATH) $(SDK_IPHONESIMULATOR_PATH)
archs = armv7 armv7s arm64 i386 x86_64
arch_names = arm-apple-darwin7 arm-apple-darwin7s arm-apple-darwin64 i386-apple-darwin x86_64-apple-darwin

libleptfolders = $(foreach arch, $(arch_names), $(LEPTON_SRC)/$(arch)/)
libtessfolders = $(foreach arch, $(arch_names), $(TESSERACT_SRC)/$(arch)/)

libleptmakefile = $(foreach folder, $(libleptfolders), $(addprefix $(folder), Makefile) )
libtessmakefile = $(foreach folder, $(libtessfolders), $(addprefix $(folder), Makefile) )
imagesmakefile = $(addprefix $(IMAGE_SRC)/, Makefile)

libleptfat = $(LIB_FAT_DIR)/$(libleptfiles)
libtessfat = $(LIB_FAT_DIR)/$(libtessfiles)
imagesfat = $(libpngfat) $(libjpegfat) $(libtifffat)
libpngfat = $(LIB_FAT_DIR)/$(libpngfiles)
libjpegfat = $(LIB_FAT_DIR)/$(libjpegfiles)
libtifffat = $(LIB_FAT_DIR)/$(libtifffiles)

libtess = $(foreach folder, $(libtessfolders), $(addprefix $(folder)/lib/, $(libtessfiles)) )
liblept = $(foreach folder, $(libleptfolders), $(addprefix $(folder)/lib/, $(libleptfiles)) )
images = $(libpng) $(libjpeg) $(libtiff)
libpng = $(addprefix $(IMAGE_LIB_DIR), $(libpngfiles))
libjpeg = $(addprefix $(IMAGE_LIB_DIR), $(libjpegfiles))
libtiff = $(addprefix $(IMAGE_LIB_DIR), $(libtifffiles))

libtessautogen = $(TESSERACT_SRC)/autogen.sh
libtessconfig = $(TESSERACT_SRC)/configure
libleptconfig = $(LEPTON_SRC)/configure

index = $(words $(shell a="$(2)";echo $${a/$(1)*/$(1)} ))
swap = $(word $(call index,$(1),$(2)),$(3))

dependant_libs = $(libtessfat) $(libleptfat) $(libpngfat) $(libjpegfat) $(libtifffat)

.PHONY : all
all : $(dependant_libs)

#######################
# TESSERACT-OCR
#######################
$(libtessfat) : $(libtess)
mkdir -p $(LIB_FAT_DIR)
xcrun lipo $^ -create -output $@
mkdir -p $(TESS_INC_DIR)
cp -rvf $(firstword $(libtessfolders))/include/tesseract $(TESS_INC_DIR)

$(libtess) : $(liblept) $(libtessmakefile)
echo $(libtess)
cd $(abspath $(@D)/..) ; \
$(MAKE) -sj8 && $(MAKE) install

$(TESSERACT_SRC)/%/Makefile : $(libtessconfig)
export LIBS="-lz -lpng -ljpeg -ltiff" ; \
export SDKROOT="$(call swap, $*, $(arch_names), $(sdks))" ; \
export CFLAGS="-I$(TESSERACT_SRC)/$*/ -L$(LIB_FAT_DIR) -Qunused-arguments -arch $(call swap, $*, $(arch_names), $(archs)) -pipe -no-cpp-precomp -isysroot $$SDKROOT -miphoneos-version-min=$(IOS_DEPLOY_TGT) -O2" ; \
export CPPFLAGS=$$CFLAGS ; \
export CXXFLAGS="$$CFLAGS -Wno-deprecated-register"; \
export LDFLAGS="-L$$SDKROOT/usr/lib/ -L$(LEPTON_SRC)/$*/src/.libs" ; \
export LIBLEPT_HEADERSDIR=$(TESSERACT_SRC)/$*/ ; \
mkdir -p $(@D) ; \
cd $(@D) ; \
ln -s $(LEPTON_SRC)/src/ leptonica ; \
../configure --host=$* --prefix=`pwd` --enable-shared=no --disable-graphics

$(libtessconfig) : $(libtessautogen)
cd $(@D) ; \
./autogen.sh

#######################
# LEPTONLIB
#######################
$(libleptfat) : $(liblept)
mkdir -p $(LIB_FAT_DIR)
xcrun lipo $^ -create -output $@
mkdir -p $(LEPT_INC_DIR)
cp -rvf $(firstword $(libleptfolders))/include/leptonica $(LEPT_INC_DIR)

$(liblept) : $(libleptmakefile)
cd $(abspath $(@D)/..) ; \
$(MAKE) -s && $(MAKE) install

$(LEPTON_SRC)/%/Makefile : $(imagesfat) $(libleptconfig)
export LIBS="-lz -lpng -ljpeg -ltiff" ; \
export SDKROOT="$(call swap, $*, $(arch_names), $(sdks))" ; \
export CFLAGS="-I$(INCLUDE_DIR) -L$(LIB_FAT_DIR) -Qunused-arguments -arch $(call swap, $*, $(arch_names), $(archs)) -pipe -no-cpp-precomp -isysroot $$SDKROOT -miphoneos-version-min=$(IOS_DEPLOY_TGT) -O2" ; \
export CPPFLAGS=$$CFLAGS ; \
export CXXFLAGS="$$CFLAGS -Wno-deprecated-register"; \
export LDFLAGS="-L$$SDKROOT/usr/lib/ -L$(LIB_FAT_DIR)" ; \
mkdir -p $(@D) ; \
cd $(@D) ; \
../configure --host=$* --prefix=`pwd` --enable-shared=no --disable-programs --with-zlib --with-libpng --with-jpeg --without-giflib --with-libtiff

#######################
# Build libtiff and all of it's dependencies
#######################
$(imagesfat) : $(images)
mkdir -p $(@D)
cp -rvf $? $(@D)
mkdir -p $(INCLUDE_DIR)
cp -rvf $(IMAGE_INC_DIR) $(INCLUDE_DIR)

$(images) : $(imagesmakefile)
cd $(IMAGE_SRC) ; \
$(MAKE) -s

#######################
# Download dependencies
#######################
$(imagesmakefile) $(libtessautogen) :
git submodule init
git submodule update

$(libleptconfig) :
curl http://leptonica.org/source/$(LEPTON_NAME).tar.gz | tar -xpf-

#######################
# Clean
#######################
.PHONY : clean
clean : cleanimages cleanlept cleantess

.PHONY : distclean
distclean : distcleanimages distcleanlept distcleantess

.PHONY : mostlyclean
mostlyclean : mostlycleanimages mostlycleanlept mostlycleantess

.PHONY : cleanimages
cleanimages :
cd $(IMAGE_SRC) ; \
$(MAKE) clean

.PHONY : cleanlept
cleanlept :
for folder in $(libleptfolders); do \
if [ -d $$folder ]; then \
cd $$folder; \
$(MAKE) clean; \
fi; \
done ;

.PHONY : cleantess
cleantess :
for folder in $(libtessfolders); do \
if [ -d $$folder ]; then \
cd $$folder; \
$(MAKE) clean; \
fi; \
done ;

.PHONY : mostlycleanimages
mostlycleanimages :

.PHONY : mostlycleanlept
mostlycleanlept :
for folder in $(libleptfolders); do \
if [ -d $$folder ]; then \
cd $$folder; \
$(MAKE) mostlyclean; \
fi; \
done ;

.PHONY : mostlycleantess
mostlycleantess :
for folder in $(libtessfolders); do \
if [ -d $$folder ]; then \
cd $$folder; \
$(MAKE) mostlyclean; \
fi; \
done ;

.PHONY : distcleanimages
distcleanimages :
-rm -rf $(IMAGE_SRC)

PHONY : distcleanlept
distcleanlept :
-rm -rf $(LEPT_INC_DIR)/leptonica
-rm -rf $(libleptfat)
-rm -rf $(LEPTON_SRC)

.PHONY : distcleantess
distcleantess :
-rm -rf $(TESS_INC_DIR)/tesseract
-rm -rf $(libtessfat)
-rm -rf $(TESSERACT_SRC)

14 changes: 3 additions & 11 deletions TesseractOCR/README_howto_compile_libaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@ First you need to install these tools:
- Automake
- Libtool

### Step 2 - Build
Run `make` in the `TesseractOCR` subfolder. This first compiles dependent libraries (png, jpeg, tiff, leptonica) and then tesseract for every architecture iOS/simulator uses (arm7 arm7s arm64 i386 x86_64), and then combines the resulting libs into one library file. It does this for both dependent libraries and tesseract, so the final results of the script are "libpng.a", "libjpeg.a", "libtiff.a", "libtesseract_all.a", "liblept.a", and "include" directories for both leptonica, tesseract and image libraries. Finally, the script copies these results into the "lib" and "include" directories inside `TesseractOCR` directory.

### Step 2 - Download and unzip
Download the source code for `leptonica-1.72` from the Internet here: http://leptonica.org/source/leptonica-1.72.tar.gz.
Unzip it in this folder.


### Step 3 - Compile
Run `build_dependencies.sh` from the terminal. This first compiles dependent libraries (png, jpeg, tiff, leptonica) and then tesseract for every architecture iOS/simulator uses (arm7 arm7s arm64 i386 x86_64), and then combines the resulting libs into one library file. It does this for both dependent libraries and tesseract, so the final results of the script are "libpng.a", "libpng16.a", "libjpeg.a", "libtiff.a", "libtiffxx.a", "libtesseract_all.a", "liblept.a", and "include" directories for both leptonica and tesseract. Finally, the script copies these results into the "lib" and "include" directories inside this directory.


### Step 4 - Build
Finally, with `Tesseract OCR iOS.xcodeproj` open in Xcode, build the target "TesseractOCRAggregate". This will use the "lib" and "include" directories to create the Tesseract OCR iOS framework.
The very first build may take half an hour or so depending on the processing power, but the later builds will not build dependencies until any files being changed.
106 changes: 0 additions & 106 deletions TesseractOCR/README_tesseract.md

This file was deleted.

0 comments on commit 2a5f817

Please sign in to comment.