NuevoSapientum / tesseract-android-tools

Automatically exported from code.google.com/p/tesseract-android-tools
0 stars 0 forks source link

Can't read file to pix #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. See code below 

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

1.00. ndk-build on debian squeeze. Eclipse helios on Windows 7, Android SDK 3.0 
API 11.

Please provide any additional information below.

Thanks for the installation instructions, everything built without any 
problems. However, when I try to read a file (I am trying ReadFile directly 
since setImage falls over at the same place) I get:

03-30 14:31:49.913: ERROR/AndroidRuntime(598): Caused by: 
java.lang.RuntimeException: Failed to read pix from file

So this is my code:

TessBaseAPI api = new TessBaseAPI();
boolean ok = api.init(dir, "eng");
String testImg = getFilesDir().toString() + "/digits.jpg";
File f = new File(testImg);
ImageView im = (ImageView) findViewById(R.id.image);
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);

}       }

The jpeg file is ok, since it displays in the ImageView, and contains digits 
0-9 (attached). I have also tried using ReadFile.readBitmap, but then I get 

03-30 12:07:56.143: ERROR/Leptonica(native)(507): Bitmap format is not supported

Any help would be appreciated.

Thanks
Ian

Original issue reported on code.google.com by ianjones1957@gmail.com on 30 Mar 2011 at 3:00

Attachments:

GoogleCodeExporter commented 8 years ago
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 ianjones1957@gmail.com on 31 Mar 2011 at 2:37

GoogleCodeExporter commented 8 years ago
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 aishwary...@gmail.com on 26 Apr 2011 at 12:39

GoogleCodeExporter commented 8 years ago
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 ianjones1957@gmail.com on 29 Apr 2011 at 3:06

GoogleCodeExporter commented 8 years ago
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 aishwary...@gmail.com on 30 Apr 2011 at 1:29

GoogleCodeExporter commented 8 years ago
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 ianjones1957@gmail.com on 1 May 2011 at 12:21

GoogleCodeExporter commented 8 years ago
Which language files did you use? And where did you locate them?

Original comment by stefan.f...@gmail.com on 4 May 2011 at 12:58

GoogleCodeExporter commented 8 years ago
Just English. From here: http://code.google.com/p/tesseract-ocr/downloads/list

Original comment by ianjones1957@gmail.com on 4 May 2011 at 1:31

GoogleCodeExporter commented 8 years ago
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 enregist...@gmail.com on 5 May 2011 at 12:31

GoogleCodeExporter commented 8 years ago
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 anirudh....@gmail.com on 5 May 2011 at 3:29

GoogleCodeExporter commented 8 years ago
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 anirudh....@gmail.com on 5 May 2011 at 3:57

GoogleCodeExporter commented 8 years ago
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 srini....@gmail.com on 5 May 2011 at 7:58

GoogleCodeExporter commented 8 years ago
Hi,

I solved the issue as you mentioned. thanks :)

Original comment by srini....@gmail.com on 5 May 2011 at 8:49

GoogleCodeExporter commented 8 years ago
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 enregist...@gmail.com on 5 May 2011 at 9:44

GoogleCodeExporter commented 8 years ago
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 srini....@gmail.com on 5 May 2011 at 11:44

GoogleCodeExporter commented 8 years ago
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 enregist...@gmail.com on 5 May 2011 at 12:07

GoogleCodeExporter commented 8 years ago
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 ianjones1957@gmail.com on 5 May 2011 at 12:44

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
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 srini....@gmail.com on 5 May 2011 at 2:41

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago

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 enregist...@gmail.com on 5 May 2011 at 4:19

GoogleCodeExporter commented 8 years ago
Hi,

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

Original comment by srini....@gmail.com on 7 May 2011 at 9:44

GoogleCodeExporter commented 8 years ago
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 bamp...@gmail.com on 16 May 2011 at 9:20

GoogleCodeExporter commented 8 years ago
Could you post your code?

Original comment by ianjones1957@gmail.com on 17 May 2011 at 12:11

GoogleCodeExporter commented 8 years ago
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 srini....@gmail.com on 17 May 2011 at 5:19

GoogleCodeExporter commented 8 years ago
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 bamp...@gmail.com on 17 May 2011 at 5:23

GoogleCodeExporter commented 8 years ago
I'll try that code when I get to my office, I'll get back to you.

Thanks Srinivasan.

Original comment by bamp...@gmail.com on 17 May 2011 at 5:27

GoogleCodeExporter commented 8 years ago
Ok, I still doesn't work, now I get "Failed to read pix from bitmap".

Original comment by bamp...@gmail.com on 17 May 2011 at 7:40

GoogleCodeExporter commented 8 years ago
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 srini....@gmail.com on 17 May 2011 at 9:29

GoogleCodeExporter commented 8 years ago
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 bamp...@gmail.com on 17 May 2011 at 10:21

GoogleCodeExporter commented 8 years ago
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 truongvd...@gmail.com on 21 Jun 2011 at 2:32

GoogleCodeExporter commented 8 years ago
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 truongvd...@gmail.com on 21 Jun 2011 at 4:10

GoogleCodeExporter commented 8 years ago
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 bamp...@gmail.com on 21 Jun 2011 at 6:14

GoogleCodeExporter commented 8 years ago
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 truongvd...@gmail.com on 22 Jun 2011 at 8:17

GoogleCodeExporter commented 8 years ago
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 truongvd...@gmail.com on 22 Jun 2011 at 4:08

GoogleCodeExporter commented 8 years ago
Hi,
you need android 2.3 or later to run tesseract successfully.

Original comment by srini....@gmail.com on 22 Jun 2011 at 4:24

GoogleCodeExporter commented 8 years ago
Any solution to run sur android 2.2 ?
Thanks

Original comment by truongvd...@gmail.com on 23 Jun 2011 at 7:05

GoogleCodeExporter commented 8 years ago
Hi,
I have the same problem described in comment #31. @truongvd... : how could you 
fix the problem?

Thanks in advance

Original comment by undosaLu...@googlemail.com on 28 Jun 2011 at 9:28

GoogleCodeExporter commented 8 years ago
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 truongvd...@gmail.com on 29 Jun 2011 at 9:22

GoogleCodeExporter commented 8 years ago
Yes, thanks a lot. Now it is also working for me.

Original comment by undosaLu...@googlemail.com on 4 Jul 2011 at 3:40

GoogleCodeExporter commented 8 years ago
@undosaLu...., what is the version Android?

Original comment by ngoisaon...@gmail.com on 7 Jul 2011 at 1:24

GoogleCodeExporter commented 8 years ago
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 kstev...@gmail.com on 13 Jul 2011 at 5:05

GoogleCodeExporter commented 8 years ago
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 kstev...@gmail.com on 13 Jul 2011 at 5:42

GoogleCodeExporter commented 8 years ago
@ngoisaon..., currently I'm testing with Android 2.2. Until now, everything 
works with that

Original comment by undosaLu...@googlemail.com on 14 Jul 2011 at 9:08

GoogleCodeExporter commented 8 years ago
Hi everyone, are there any ways that this library would support Android 2.1? 

Original comment by rendec...@gmail.com on 19 Jul 2011 at 9:33

GoogleCodeExporter commented 8 years ago
This project does in fact work for Android 2.2.  Comment 21 by 
enregist...@gmail.com, May 5, 2011 is the answer.  You need to pull from trunk. 
 The downloadable package only works for android 2.3

Original comment by asharif....@gmail.com on 27 Jul 2011 at 4:24

GoogleCodeExporter commented 8 years ago
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 asnr_akh...@yahoo.com on 12 Aug 2011 at 12:07

GoogleCodeExporter commented 8 years ago
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 
asharif....@gmail.com, in Comment 46:

build from trunk (SVN) instead of the download.

It now works for me.

Original comment by jopvanra...@gmail.com on 15 Aug 2011 at 9:37

GoogleCodeExporter commented 8 years ago
asnr_akh...@yahoo.com:

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 ianjones1957@gmail.com on 17 Aug 2011 at 10:24

Attachments:

GoogleCodeExporter commented 8 years ago
@asnr_akh...@yahoo.com @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 tmanand@gmail.com on 21 Sep 2011 at 7:28