I built the tesseract ocr for android using android tesseract tool and everything went fine. I also got the library files. When I tried to use the java wrappers to access the native methods, the device crashes. I’m using the tesseract directly in camera callback.
The code looks something like this:
public class AndroidCamera extends Activity implements SurfaceHolder.Callback {
TessBaseAPI tba;
PictureCallback myPictureCallback_JPG = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera arg1) {
Bitmap bitmapPicture = BitmapFactory.decodeByteArray(data, 0, data.length);
tba = new TessBaseAPI();
tba.setImage(bitmapPicture);
String result = tba.getUTF8Text();
Log.i("text: "+result);
Toast.makeText(AndroidCamera.this,result,Toast.LENGTH_LONG).show();
}
camera.startPreview();
};
}
I checked in the log cat still setimage it’s working fine, in the tba.getUTF8Text() the device crashes.
I don’t see any engine initialization code with the desired language. This is done by calling the init method with the language/directory.
Trained data can be downloaded here: http://code.google.com/p/tesseract-ocr/downloads/list