6

I am trying to use Tesseract OCR Library in order to create a program to read pictures of elevator floor numbers. I haven't found any example on how to include the Tesseract Library into a C++ file. Something like:

#include "tesseract.h"

I am using Tesseract v 3.00 on Ubuntu 10.10.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
locorecto
  • 1,178
  • 3
  • 13
  • 40
  • 3
    That probably won't be enough. I know nothing about Tesseract OCR library but you will require the include directives, plus specify the directory to where the Tesseract header files are installed via a compiler switch (usually `-I`) and (possibly) link with the Tesseract library file(s). – hmjd Feb 05 '12 at 20:46
  • Why can't it be enough. I have already installed Tesseract on my system. For openCV for example you only need to do #include "cv.h" and "using namespace cv";. After installing the library it is definitely not as complicated as you mentioned. – locorecto Feb 05 '12 at 21:39
  • 1
    That would be enough to compile the sources if the header files are installed into common include directories. However, if the header files do not contain the definitions (not just declarations) for all functions/variables then there will be a library file(s) (like `libtesseract.a` or/and `libtesseract.so`) that must be linked in order to compile your binary. – hmjd Feb 05 '12 at 21:43
  • You did install `libtesseract-dev`, right? – Mike Kwan May 28 '12 at 23:12

1 Answers1

8

The PlatformStatus Page has some comments on how to install it. It has dependencies (leptonica) which also need to be installed.

Another solution also linked from the above discussion has similar details for other linux distributions.

When it comes to linking with your program, this post has some specifics

There is also a C wrapper to the underlying API calls; looking at the files included should tell you what to include. Other wrappers are available here.

The documentation of the base API class are here...

A comment from the Platform Status page for the installation.

Comment by tim.lawr...@gmail.com, Nov 23, 2011 I successfully installed tesseract-ocr on Ubuntu 11.10 64Bit using these commands:

sudo apt-get install libleptonica-dev autoconf automake libtool libpng12-dev libjpeg62- dev libtiff4-dev zlib1g-dev subversion g++
cd
svn checkout http://tesseract-ocr.googlecode.com/svn/trunk/ tesseract-ocr
cd tesseract-ocr
./autogen.sh
./configure
make
sudo make install
sudo ldconfig
cd /usr/local/share/tessdata/
sudo wget http://tesseract-ocr.googlecode.com/files/eng.traineddata.gz
sudo gunzip eng.traineddata.gz
cd ~/tesseract-ocr/
tesseract phototest.tif phototest
cat phototest.txt
Community
  • 1
  • 1
VSOverFlow
  • 1,025
  • 8
  • 11