0

I am following this tutorial and manage to build the library just fine.

My State Now:

  • I take a photo, save it to the external memory (here is the directory path)

    static String directoryPath = Environment.getExternalStorageDirectory().toString() + "/saved_images";
    
  • In the directory there are currently only pictures I took in jpg format.

  • I can load a bitmap from the saved image.

The problem-

I couldn't understand how do I use this piece of code:

TessBaseAPI baseApi = new TessBaseAPI();
// DATA_PATH = Path to the storage
// lang = for which the language data exists, usually "eng"
baseApi.init(DATA_PATH, lang);
// Eg. baseApi.init("/mnt/sdcard/tesseract/tessdata/eng.traineddata", "eng");
baseApi.setImage(bitmap);
String recognizedText = baseApi.getUTF8Text();
baseApi.end();
  • What is the DATA_PATH variable?
  • also read something about creating a folder named tesseract and putting there language files?

not really sure what I need to do and the tutorial doesn't explain it.

any help would be appreciated!

n1nsa1d00
  • 856
  • 9
  • 23
Ofek Agmon
  • 5,040
  • 14
  • 57
  • 101
  • you need to download a traineddata file and store this in your device, try with this [link](https://code.google.com/p/tesseract-ocr/downloads/detail?name=tesseract-ocr-3.02.eng.tar.gz&can=2&q=) and copy in your device the "eng.traineddata" file. DATA_PATH is the path to the file that you added. – Lesther Vega Apr 30 '15 at 17:34
  • thanks for your answer. does the eng.traineddata file and the images files should all bein the same folder? and DATA_PATH is the path to the folder? or to the file? – Ofek Agmon Apr 30 '15 at 18:24
  • DATA_PATH is the path to the file and not import where you put this. – Lesther Vega Apr 30 '15 at 19:14
  • I didnt understand where should i put the eng. Traineddata file.. – Ofek Agmon Apr 30 '15 at 21:12

1 Answers1

1

put the file in your devices (download folder for example)

File Manager

Open the file properties in your devices:

Devices properties

and copy the path in your DATA_PATH var, for example: /mnt/sdcard/download/eng.traineddata

the TessBaseAPI need the file for initialization.

Lesther Vega
  • 528
  • 3
  • 14
  • thanks for your answer. now the init is fine, but text I am getting is a real mess.. do you have it working fine? I asked another question about it here - http://stackoverflow.com/questions/29984673/android-recognized-text-from-tess-two-library-is-wrong help would be appreciated – Ofek Agmon May 03 '15 at 06:37