Skip to content

Commit

Permalink
Merge pull request #1 from EliasKotlyar/master
Browse files Browse the repository at this point in the history
Add Ubuntu 14.04 Support
  • Loading branch information
guitarmind committed Jul 6, 2015
2 parents 6b2aa08 + beb8db5 commit d214454
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,48 @@ To start it as a persistent service even after terminal logout:

sudo nohup python /opt/ocr/tesseractserver.py -p 8080 -b "/home/markpeng/local/lib" -d "/home/markpeng/local/share/tesseract-ocr" &

####Tesseract Installation on Ubuntu 14.04 LTS

Python Requirement

version >= 2.7

Install tornado, PIL image library and other required packages by apt-get.

sudo apt-get update && sudo apt-get install -y \
autoconf \
automake \
autotools-dev \
build-essential \
checkinstall \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libtool \
python \
python-imaging \
python-tornado \
wget \
zlib1g-dev

Install the tesseract library:

sudo apt-get install tesseract-ocr-dev

Correct the Filename( or use this Repository):

class TesseactWrapper:
def __init__(self, lang, libpath, tessdata):
libname = libpath + "/libtesseract.so.3.0.3"



Now, start tesseract-web-service by:

python tesseractserver.py -p 1688 -b /usr/lib -d /usr/share/tesseract-ocr/tessdata/



####How to call RESTful API by GET/POST request
The web service provides two HTTP GET pages for testing the API:

Expand Down
17 changes: 11 additions & 6 deletions tesseractcapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,23 @@
"""
class TesseactWrapper:
def __init__(self, lang, libpath, tessdata):
libname = libpath + "/libtesseract.so.3.0.2"
libname_302 = libpath + "/libtesseract.so.3.0.2"
libname_303 = libpath + "/libtesseract.so.3.0.3"
libname_alt = "/libtesseract.so.3"

try:
self.tesseract = ctypes.cdll.LoadLibrary(libname)
self.tesseract = ctypes.cdll.LoadLibrary(libname_302)
except:
try:
self.tesseract = ctypes.cdll.LoadLibrary(libname_alt)
self.tesseract = ctypes.cdll.LoadLibrary(libname_303)
except:
print("Trying to load '%s'..." % libname)
print("Trying to load '%s'..." % libname_alt)
exit(1)
try:
self.tesseract = ctypes.cdll.LoadLibrary(libname_alt)
except:
print("Trying to load '%s'..." % libname)
print("Trying to load '%s'..." % libname_alt)
print("Loading failed from the locations above.")
exit(1)

self.tesseract.TessVersion.restype = ctypes.c_char_p
tesseract_version = self.tesseract.TessVersion()
Expand Down

0 comments on commit d214454

Please sign in to comment.