ShazibAli / tesseract-android-tools

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

Can't read file to pix #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 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 9 years ago
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 ianjones1957@gmail.com on 22 Sep 2011 at 9:13

GoogleCodeExporter commented 9 years ago
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 tahir90....@gmail.com on 11 Dec 2011 at 8:32

GoogleCodeExporter commented 9 years ago
Removed libjpeg and added native bitmap support. Should be obsolete.

Original comment by alanv@google.com on 11 Sep 2012 at 8:16