Pallav Singh
Pallav Singh

Reputation: 103

How to configure Tesseract in Eclipse for Android development?

I have been working on android from 6 months. So I have basic idea about Android development. Now I want to develop an OCR Android app using Tesseract. For that I have downloaded android-ndk-r6b, tess-two from Tesseract, Cygwin for Windows and installed C/C++ developer in Eclipse.

And I followed these two links:

1.http://www.itwizard.ro/interfacing-cc-libraries-via-jni-example-tesseract-163.html

2.http://gaut.am/making-an-ocr-android-app-using-tesseract/

but I got stuck in between. I mean I am not able to configure these things together.

Can anyone suggest me how to configure tesseract in Android from beginning (step by step)?

Upvotes: 7

Views: 7423

Answers (3)

khyati pandya
khyati pandya

Reputation: 5

  1. Download tesseract library for android Download as .zip for windows, as .tar.gz for linux user.

  2. Software requirement

    • Eclipse
    • Java JDK
    • Android SDK
    • Android NDK
    • Cygwin ( for windows users)
    • Apache-ant
  3. For windows user, make sure you already installed cygwin ( you can download it and install it f make sure during the cygwin installation, install also these source and library gcc-core, gcc-g++, make, swig)

  4. Download apache-ant from[http://ant.apache.org/bindownload.cgi ] choose .zip for windows, .tar.bz for linux user.

  5. Unzip the apache and set the environment variable (mine is C:\apache-ant-1.8.3\bin)

  6. Run cygwin (for windows user only,for linux user,run terminal) a.cd /tess-two

    b.export TESSERACT_PATH=${PWD}/external/tesseract-3.01

    c.export LEPTONICA_PATH=${PWD}/external/leptonica-1.68

    d.export LIBJPEG_PATH=${PWD}/external/libjpeg

    e.ndk-build(for windows user, /cygdrive//ndk-build)

    f. android update project --path . (for windows user, sometime cygwin cannot execute this command, so use command prompt to execute this command). Note: The “.” after --path must be included in the command. g. ant release ( sometimes you will get error like java tools.jar not found, set environment variable JAVA_HOME to the jdk folder, mine is C:\Program Files\Java\jdk1.7.0)

  7. Run Eclipse. Right click on package explorer, import>> General >> Existing Project into Workspace >> Next >> Select Root Directory >> Browse the tess-two folder location >> Finish. You will see tess-two folder in your package explorer.

  8. Right click on the project >> Android Tools >> Fix Project Properties. Right click >> Properties >> Android >> Check Is Library. Download the simple OCR android app from [https://github.com/GautamGupta/Simple-Android-OCR.] Right click on package explorer, import the simple OCR android app folder.
  9. Right click on the project >> Android >> Add >> click tess-two >> OK
  10. Run the app. Good luck

Upvotes: 0

Kevin D.
Kevin D.

Reputation: 1510

https://github.com/rmtheis/tess-two a fork of the Tesseract Android Tools with added functionality

This works for SDK r16 and NDK r7 (or the latest, depending on when you are reading this)

check the README for the guide.

I'm not sure if this works for Cygwin.

git clone git://github.com/rmtheis/tess-two tess
cd tess/tess-two
ndk-build
android update project --path .
ant release

If you don't want to set the environment, you can type out the absolute path like: /home/user/android-ndk-r7/ndk-build since your using windows, it would look something like C:\<path to ndk>\ndk-build

same thing with android update project --path . you can do something like C:\<path to sdk>\tools\android update project --path . (I had to specify the target by adding android update project -t 10 --path . for Android 2.3.3 )

When you're done, you can then import the tess-two project to Eclipse. Make sure tess-two is a library (you can check in Properties > Android > Library (beneath build target) )

be sure you have downloaded SDK r16 and use NDK r7 (or the latest, depending on when you are reading this) otherwise building will result in an error.

Upvotes: 3

rmtheis
rmtheis

Reputation: 5836

The instructions at your link #2 don't work using cygwin--you have to build using Linux. I've verified that those instructions work. So try using Linux instead of cygwin.

If you're using the instructions at your link #2, you don't need the instructions at your link #1 at all--it has what you need in JNI already available.

Upvotes: 2

Related Questions