Giter Site home page Giter Site logo

Comments (53)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
UPDATE: so it does work on a real phone, but not on the emulator. At least it 
works on my Nexus 1 running Android 2.3.3.

Regards
Ian

Original comment by [email protected] on 31 Mar 2011 at 2:37

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,

In the code u have given,
boolean ok = api.init(dir, "eng");
 can u please share,what does the "dir" refer to?

Thanks in Advance,



Original comment by [email protected] on 26 Apr 2011 at 12:39

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
dir is a String containing the parent directory of the tessdata directory, in 
this case dir = "/mnt/sdcard/".

Further update: it seems to have something to do with the version of Eclipse. 
It didn't work on Helios V2, but on v3.6.2 with the same Android SDK it works!

Ian

Original comment by [email protected] on 29 Apr 2011 at 3:06

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Thanks for the reply Ian,

I have compiled the tesseract,leptonica and libjpeg in Ubuntu Linux as per the 
instructions given in "read me" in tesseract-android-tools.I am also able to 
initialize the tesseract engine.When I try to call "setImage" method passing 
image in bytes format,it is accepting the image , but returning some different 
junk characters every time(it is changing each time for same image) on calling 
getUTF8Text.

I even tried calling "setImage" method passing Bitmap image, but it is 
returning"Bitmap functions not available; library must be compiled under 
android-8 NDK" Error.
libjnigraphics.so is present in my library.

We are using Eclipse ganymade 3.5.2 for this.Macro declaration for Leptonica 
and ZLib has been included in "config_auto.h" which were missing.

Can you please share any solution as we are struck with it quite long.Thanks in 
advance

Original comment by [email protected] on 30 Apr 2011 at 1:29

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
I am certainly no expert on tesseract, so I can only tell you what I did to get 
it to work:

- Compile tesseract and leptonica on a Debian machine (obviously Ubuntu should 
work too.)

- Upgrade Eclipse, Helios, Eclipse SDK, version 3.6.2 works for me.

- Import the tesseract project and set is as a library. I set the build target 
as Android 2.2.

- Create a test project, same build target.

- You are correct that it doesn't work with bitmaps, which is very unfortunate. 
The only way I could get it to work was so save the image as a jpeg file, then 
pass the jpeg to tesseract to scan. This is obviously not very efficient, but 
it's the only thing I could get to work:

TessBaseAPI api = new TessBaseAPI();
boolean ok = api.init(tessParentDir+"/", "eng");
if ( !ok ) {
  l.error("Failed to initialize api");
  return;
}
File f = new File(testImg); // testImg = "/mnt/sdcard/test.jpg"
if (f == null || !f.canRead() || f.length() < 1) {
  l.error(testImg + " is not readable");
} else {
  l.info("Trying to read file", 4);
  try {
    Pix px = ReadFile.readFile(f);
    api.setImage(px);
    l.info("File read", 4);
    String text = api.getUTF8Text();
    l.info("Text is >>>" + text + "<<<", 1);
    TextView tv = (TextView) findViewById(R.id.result);
    tv.setText(text);
  } catch (Exception e) {
    l.error("Failed to read test image " + e.getMessage());
  }
}
api.end();

I suggest you try this with test image I uploaded.

Good luck!
Ian

Original comment by [email protected] on 1 May 2011 at 12:21

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Which language files did you use? And where did you locate them?

Original comment by [email protected] on 4 May 2011 at 12:58

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Just English. From here: http://code.google.com/p/tesseract-ocr/downloads/list

Original comment by [email protected] on 4 May 2011 at 1:31

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
i tried ianjones method :

1/ downloaded the ndk & tesseract tools project with the README
2/ compiled it on debian 
4/ create a project based on android 2.1 on Eclipse (win 7)
5/ copied the 3 .so (libjpeg/libtess/liblept in libs folder
6/ copied TessBaseAP.java in my package project

When i start the program i have this errors :
"No implementation found for native Lcom/test/TessBaseAPI";.nativeClassInit ()V
"Exception Ljava/lang/UnsatisfiedLinkError; thrown during 
Lcom/test/TessBaseAPI;. <clinit>"

i realy don't understand... I tried many many diferent ways, but unsuccessfully 

Original comment by [email protected] on 5 May 2011 at 12:31

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
I understand this an issue tracker but since there doesn't seem to be a forum 
I'll ask my question right here since its related,

I've got the project compiled and a sample app up. I placed the downloaded 
english language data files i.e. eng.traineddata under /mnt/sdcard/tessdata.

 I see this abrupt crash on api.init() 

D/dalvikvm(26619): Trying to load lib /data/data/com.appname.../lib/liblept.so 
0x40513f58
D/dalvikvm(26619): Added shared lib /data/data/com.appname.../lib/liblept.so 
0x40513f58
D/dalvikvm(26619): Trying to load lib /data/data/com.appname...t/lib/libtess.so 
0x40513f58
D/dalvikvm(26619): Added shared lib /data/data/com.appname.../lib/libtess.so 
0x40513f58
V/Tesseract(native)(26619): 
Java_com_googlecode_tesseract_android_TessBaseAPI_nativeClassInit
V/Tesseract(native)(26619): 
Java_com_googlecode_tesseract_android_TessBaseAPI_nativeConstruct
V/Tesseract(native)(26619): 
Java_com_googlecode_tesseract_android_TessBaseAPI_nativeInit
I/Tesseract(native)(26619): Attempting Init() with dir=/mnt/sdcard/tessdata/, 
lang=eng
I/ActivityManager(  107): Process com.appname....tesseract (pid 26619) has died.


My Code:

public class TesseractApp extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        File sdcard = Environment.getExternalStorageDirectory();
        File from = new File(sdcard, "Pic.jpg");
        TessBaseAPI api = new TessBaseAPI();
        api.init("/mnt/sdcard/tessdata/", "eng");
        api.setImage(from);
        Log.d("OCR", api.getUTF8Text());
    }
}

Original comment by [email protected] on 5 May 2011 at 3:29

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
I figured out that the directory name has to be "tessdata" and the library will 
append that to the path you provide. In this case /mnt/sdcard/ was enough.

It's working now and I can get some results. The results are not as good as I 
expected but I am happy i've got something working on device and the OCR is 
fast.

Original comment by [email protected] on 5 May 2011 at 3:57

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,

Im also facing the same problem. when i pass a bitmap to setimage(bitmap) 
method, its showing the error "Bitmap functions not available; library must be 
compiled under android-8 NDK"but i complied under android-8 ndk. 

how to solve the problem?

Regards,
Srinivasan 

Original comment by [email protected] on 5 May 2011 at 7:58

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,

I solved the issue as you mentioned. thanks :)

Original comment by [email protected] on 5 May 2011 at 8:49

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Yep so the steps to make it works  :

create folder "/sdcard/tessdata/"
put your language ("lang.traineddata", not the .gz) files in the folder
in your code, api.init("/mnt/sdcard/", "lang");

Voila !

Thanks to anirudith ;)

Original comment by [email protected] on 5 May 2011 at 9:44

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,

reading the image as pix and setimage(pix) is working fine in emulator but when 
I tried in my device its showing 
             "Failed to read pix from file"
where we trying to read the jpg file from disk and converting it to pix. 

I mentioned the path correctly and im having that jpg image in the sdcard.

Im using HTC incredible with android v2.2. how to solve it?

thanks,
srinivasan

Original comment by [email protected] on 5 May 2011 at 11:44

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
I also have the "failed to read pix from file"
on the device & the emultaor...

I really don't know where could  be the solution 

Original comment by [email protected] on 5 May 2011 at 12:07

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Since I started this, I will provide a summary of what worked for me. I’m not 
suggesting that this is how it must be done - it’s just how I got it work.

Create a test image file (you can use the one I uploaded above) and put it 
somewhere readable by the application. Make sure this file is readable, you can 
use a filesystem explorer to verify the file, and as in my code above, display 
the image in an ImageView in the application just to be sure it’s readable by 
the application.

Create a directory called tessdata readable by the application (I used 
/mnt/sdcard/tessdata). Place a language file (see above for the link) in this 
directory (I have just tried the English one.)

When you initialize with .init(dir,lang), make sure the directory name 
terminates in “/” (“/mnt/sdcard/” in this case) and the String lang 
corresponds to the language file you put in the tessdata directory “eng” in 
this case.

My test code is above, in summary:

TessBaseAPI api = new TessBaseAPI();
boolean ok = api.init(tessParentDir+"/", "eng");
if ( !ok ) {
  Log.e("ocr","Failed to initialize api");
  return;
}
File f = new File(testImg); // test image file including path.
if (f == null || !f.canRead() || f.length()<1 ) {
  Log.e("ocr", testImg+ " is not readable");
} else {
  Log.i("ocr", "Trying to read file");
  Pix px = ReadFile.readFile(f);
  api.setImage(px);
  Log.i(“ocr”,"File read");
  String text = api.getUTF8Text();
  Log.i(“ocr”,"Text is >>>" + text + "<<<");
}

In my experience, this will only work on the emulator with some versions of 
Eclipse. However, it seems to work on a real device, at least on my Nexus One. 
It took me a long time to get it work. Defensive programming, i.e. checking 
success/failure after each operation, is essential in tracking down where it 
goes wrong. 

This discussion would suggest that a Tesseract/Android forum would be a welcome 
addition. I hope someone can create one.

Regards
Ian

Original comment by [email protected] on 5 May 2011 at 12:44

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
[deleted comment]

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,

I'm having HTC incredible. it is also using android 2.2. Im also facing the 
same problem. 

If we upgrade the android version will it work? by the way I to try with you to 
find an alternate solution.. 

Let me know if you find any .. 

thanks,
Srinivasan

Original comment by [email protected] on 5 May 2011 at 2:41

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
[deleted comment]

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
[deleted comment]

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024

The owner of the project didn't put the latest version of the sources in the 
download section.
You can get the latest version of the project with a svn checkout 
http://tesseract-android-tools.googlecode.com/svn/trunk/

For Windows and to build Android 2.2 app :

1/ downloaded the ndk & tesseract tools (svn) project with the README

2/ build it on debian(vmware)  with the ndk 

3/ tesseract tools is actually a library and has a eclipse .project so just 
import that project after building the so's with ndk and build it.

4/ Set it as lib : 
http://developer.android.com/guide/developing/projects/projects-eclipse.html#Set
tingUpLibraryProject

5/ Now in the same workspace create a new android project i.e. your app. Go to 
properties and reference the library from step 3 
(http://developer.android.com/guide/developing/projects/projects-eclipse.html#Re
ferencingLibraryProject)

6/ Build your app based on Android 2.2 (min) : 
http://code.google.com/p/tesseract-android-tools/issues/detail?id=5#c16

And it should work !

Thanks to ianjones1957 who help me a lot

Original comment by [email protected] on 5 May 2011 at 4:19

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,

I thank you both of them who helped me to solve the issue. Thanks a lot once 
again

Original comment by [email protected] on 7 May 2011 at 9:44

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi, I've read all your comments but I still have the "failed to read pix from 
file" error.

I've manged to make it work on my Nexus One (2.3.4) but the same program won't 
run on a Samsung Galaxy S (2.2), do you have any idea why this is happening?

Thanks in advance.

Regards.

Original comment by [email protected] on 16 May 2011 at 9:20

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Could you post your code?

Original comment by [email protected] on 17 May 2011 at 12:11

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,
check your ReadFile.java. If 2.2 or below you are not supposed to get this 
error. It will go to the else part in the below code.

 public static Pix readFile(File file) {
        if (file == null)
            throw new IllegalArgumentException("File must be non-null");
        if (!file.exists())
            throw new IllegalArgumentException("File does not exist");
        if (!file.canRead())
            throw new IllegalArgumentException("Cannot read file");

        // TODO Fix support for JPEG library in Android 2.2 & lower
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
            final int nativePix = nativeReadFile(file.getAbsolutePath());

            if (nativePix == 0)
                throw new RuntimeException("Failed to read pix from file");

            return new Pix(nativePix);
        } else {
            final BitmapFactory.Options opts = new BitmapFactory.Options();
            opts.inPreferredConfig = Bitmap.Config.ARGB_8888;

            final Bitmap bmp = BitmapFactory.decodeFile(file.getAbsolutePath(), opts);
            final Pix pix = readBitmap(bmp);

            bmp.recycle();

            return pix;
        }
    }

it will be in this fashion. and I think you are using some older version of 
tesseract android tools.

You can get the latest version of the project with a svn checkout 
http://tesseract-android-tools.googlecode.com/svn/trunk/

as mentioned in the : 
http://code.google.com/p/tesseract-android-tools/issues/detail?id=5#c21

Original comment by [email protected] on 17 May 2011 at 5:19

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Sure, actually I do exactly what you posted here:

TessBaseAPI api = new TessBaseAPI();
boolean ok = api.init(Environment.getExternalStorageDirectory() + "/", "spa");

if ( !ok ) {
    Log.e("ocr","Failed to initialize api");
    return;
}

File f = new File(Environment.getExternalStorageDirectory() + 
"/tessdata/eurotext.jpg"); // test image file including path.

if (f == null || !f.canRead() || f.length()<1 ) {
    Log.e("ocr", f + " is not readable");
} else {
    Log.i("ocr", "Trying to read file");
    Pix px = ReadFile.readFile(f);
    api.setImage(px);
    Log.i("ocr","File read");
    String text = api.getUTF8Text();
    Log.i("ocr","Text is >>>" + text + "<<<");
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText(text);
}

Original comment by [email protected] on 17 May 2011 at 5:23

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
I'll try that code when I get to my office, I'll get back to you.

Thanks Srinivasan.

Original comment by [email protected] on 17 May 2011 at 5:27

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Ok, I still doesn't work, now I get "Failed to read pix from bitmap".

Original comment by [email protected] on 17 May 2011 at 7:40

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,

check the image file extension. I think eurotext file is .tif format. It 
mentioned as it will support only jpeg and bmp. try wit some other image.

Regards,
srinivasan

Original comment by [email protected] on 17 May 2011 at 9:29

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi, thanks for the reply.

The image is a jpg file, I converted it on my computer and copied it to my 
sdcard.
I also tried the digits.jpg file that you can find earlier in this post.

It definitely seems an android version problem, I successfully executed the 
application on a 2.3 emulator.

It's weird since the target version on the AndroidManifest states 8 as min sdk 
version.


Regards.

Original comment by [email protected] on 17 May 2011 at 10:21

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hello
I have problem:
Process com.... has died when TessBaseAPI.init
Code:
 TessBaseAPI api = new TessBaseAPI();
 boolean ok = api.init("/mnt/sdcard/", "eng");
 if ( !ok ) {
      //lblMessage.setText("Failed to initialize api");
      return;
 }
 I build tessecard-android-tools on ubuntu 10.0.4
 Smartphone is acer stream android 2.2
 Thanks

Original comment by [email protected] on 21 Jun 2011 at 2:32

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hello
I fix my problem. But, i have new problem : "Failed to read pix from bitmap".
I create file image par paint, save file .bmp or .jpg
Help me
Thanks

Original comment by [email protected] on 21 Jun 2011 at 4:10

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi, 

First of all, what I'd do is, instead of referring directly to the sdcard 
directory try Environment.getExternalStorageDirectory() just to be sure it's 
getting the right path.

In my case it would only work with jpg images and as I mentioned before, I 
would get the same error "Failed to read pix from bitmap" unless I executed it 
in a 2.3 sdk version emulator.

I hope I helped.

Regards.

Original comment by [email protected] on 21 Jun 2011 at 6:14

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,

The path of image is right. I display image sur InageView: ok
With the type of image, I create image on paint or use smartphone take picture. 
The type is jpg.
Code:
Pix px = ReadFile.readFile(fileLoad);
api.setImage(px);
String text = api.getUTF8Text();
lblMessage.setText(text);

I use tessecart 3.0.0
build sur ubuntu 10.0.4 comme README
Help me
Thanks

Original comment by [email protected] on 22 Jun 2011 at 8:17

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi
I try to use image digits.jpg. But i have this error.
I use smartphone acer stream with android 2.2
Thanks

Original comment by [email protected] on 22 Jun 2011 at 4:08

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,
you need android 2.3 or later to run tesseract successfully.

Original comment by [email protected] on 22 Jun 2011 at 4:24

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Any solution to run sur android 2.2 ?
Thanks

Original comment by [email protected] on 23 Jun 2011 at 7:05

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi,
I have the same problem described in comment #31. @truongvd... : how could you 
fix the problem?

Thanks in advance

Original comment by [email protected] on 28 Jun 2011 at 9:28

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
In the sdcard, i create forder "tessdata". I download file "eng.traineddata" 
and copy this file in the folder.
I hope help you

Original comment by [email protected] on 29 Jun 2011 at 9:22

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Yes, thanks a lot. Now it is also working for me.

Original comment by [email protected] on 4 Jul 2011 at 3:40

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
@undosaLu...., what is the version Android?

Original comment by [email protected] on 7 Jul 2011 at 1:24

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
I can confirm that error 07-13 java.lang.RuntimeException: Failed to read pix 
from file is present on the real device (HTC Desire, 2.2) and not in emulator 
(2.3.3).

Original comment by [email protected] on 13 Jul 2011 at 5:05

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi all. The problem might be solved. Since lib won't read files on Android 2.2 
and I didn't like the process of saving files to SD card, I found a workaround: 
convert Bitmap to 8bpp picture. Since I don't have knowledge of image 
manipulation, someone has to do it properly. Here is code that accepts only one 
color from 4 bytes per pixel image:


        Drawable d = getResources().getDrawable(R.drawable.hello);
        Bitmap bmp = ((BitmapDrawable)d).getBitmap();

        byte[] store = new byte[bmp.getWidth()*bmp.getHeight()*4];
        ByteBuffer buffer = ByteBuffer.wrap(store);
        bmp.copyPixelsToBuffer(buffer);

        byte[] bmpData = new byte[store.length/4];
        int c = 0;
        for (int i=0; i<store.length; i++) {
            if (i%4==1) {
                bmpData[c] = store[i];
                c++;
            }
        }

        TessBaseAPI tess = new TessBaseAPI();
        boolean ok = tess.init("/sdcard/", "eng");
        if (!ok) {
            Log.e("TEST", "TESS DICT FAILED");
        }
        tess.setDebug(true);
        Pix px = ReadFile.readBytes8(bmpData, bmp.getWidth(), bmp.getHeight());
        tess.setImage(px);
        String str = tess.getUTF8Text();

And it works on a simple image ;)

Hope this helps.

Original comment by [email protected] on 13 Jul 2011 at 5:42

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
@ngoisaon..., currently I'm testing with Android 2.2. Until now, everything 
works with that

Original comment by [email protected] on 14 Jul 2011 at 9:08

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Hi everyone, are there any ways that this library would support Android 2.1? 

Original comment by [email protected] on 19 Jul 2011 at 9:33

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
This project does in fact work for Android 2.2.  Comment 21 by 
[email protected], May 5, 2011 is the answer.  You need to pull from trunk. 
 The downloadable package only works for android 2.3

Original comment by [email protected] on 27 Jul 2011 at 4:24

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
hi everybody,
first of all i would like to thank everybody, especially IANJONES whose 
guidence is very helpful in executing my app.

But i was hooked up with an issue,
I have compiled the tesseract,leptonica and libjpeg in Ubuntu Linux as per the 
instructions given in "read me" in tesseract-android-tools.I am also able to 
initialize the tesseract engine. But, after completing the scanning part, it is 
returning some different junk characters every time on calling getUTF8Text(). 
Please refer the code below.
TessBaseAPI api = new TessBaseAPI();
boolean ok = api.init("/mnt/sdcard/tesseract/","eng");
if ( !ok ) {
Log.e("ocr","Failed to initialize api");
return;
}
File f = new File("/mnt/sdcard/tesseract/tessdata/3.jpg");
if (f == null || !f.canRead() || f.length() < 1) {
                    Log.e("ocr","/mnt/sdcard/tesseract/tessdata/3.jpg"  + " is not readable");
} else {
Log.i("ocr", "Trying to read file");
try {
Pix px = ReadFile.readFile(f);
api.setImage(px);
Log.i("ocr","File read");
String text = api.getUTF8Text();                                                                            
Intent myIntent = new Intent(TTS.this,scndtxt.class ).putExtra("Text", text);   
                                startActivity(myIntent);                                         

} catch (Exception e) {
Log.e("Failed to read test image " + e.getMessage());
}
}

Can you please share a solution for this problem. I was struck due to this 
issue since a couple of weeks. Hope you would take out some time and help me 
out with this

thanks in advance

Original comment by [email protected] on 12 Aug 2011 at 12:07

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
I had the same problem (java.lang.RuntimeException: Failed to read pix from 
file) on a Android 2.2 Emulator. I can confirm the remark of 
[email protected], in Comment 46:

build from trunk (SVN) instead of the download.

It now works for me.

Original comment by [email protected] on 15 Aug 2011 at 9:37

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
[email protected]:

I think you have probably reached the limit of Tesseract, at least on Android. 
I have found that the image needs to be extremely clear for Tesseract to make 
sense of it, otherwise you just get a lot of junk as you have described. For 
example, I cannot get Tessseract to scan successfully the attached image. It's 
a bit disappointing :-(

Regards
Ian

Original comment by [email protected] on 17 Aug 2011 at 10:24

Attachments:

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
@[email protected] @ianjones1957
tesseract expects uncompressed image. You'll get garbage if you're sending it a 
compressed image (like the jpg you've attached)

Original comment by [email protected] on 21 Sep 2011 at 7:28

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
If tesseract requires an uncompressed image, why then does it support jpeg? As 
detailed above, since the Android implementation doesn't work with bitmaps, 
there's no alternative. (Setting the jpeg quality in the camera parameters with 
setJpegQuality(100) doesn't help.)

Original comment by [email protected] on 22 Sep 2011 at 9:13

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Iam using Eclipse for developing android app.

while testing tesseract API I got this error: " tesseract-android-tools] Could 
not find tesseract-android-tools.apk! " what does it mean and what should i do 
please help!

below is the code Iam using and there is no error in this code :

package ocr.text.phase1;

import java.io.File;

import com.googlecode.leptonica.android.Pix;
import com.googlecode.leptonica.android.ReadFile;
import com.googlecode.tesseract.android.TessBaseAPI;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

public class OcrtextActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

 TessBaseAPI api = new TessBaseAPI();
        boolean ok = api.init("D:/android/workspace/tesseract-android-tools/tessdata/", "eng");
        String testImg = getFilesDir().toString() + "/javac.jpg";
        File f = new File(testImg);

        ImageView im = new ImageView(null);
        Bitmap bm = BitmapFactory.decodeFile(testImg);
        im.setImageBitmap(bm);
        if (f == null || !f.canRead() || f.length()<1 ) {
          Log.e("ocr", testImg+ " is not readable");
        } else {
          Log.i("ocr", "Trying to read file");
          Pix px = ReadFile.readFile(f);

        }
    }
    }



What version of the product are you using? On what operating system?

My Eclipse version is : Helios Service Release 2

Operating System is : Windows XP

Please Reply as soon as possible Iam waiting! thanks!

Original comment by [email protected] on 11 Dec 2011 at 8:32

from tesseract-android-tools.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
Removed libjpeg and added native bitmap support. Should be obsolete.

Original comment by [email protected] on 11 Sep 2012 at 8:16

  • Changed state: Fixed

from tesseract-android-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.