0

I wrote a sample Android app. I am getting 'Tesseract(native): Could not initialize Tesseract API with language=eng!' error.

I did include compile 'com.rmtheis:tess-two:5.4.0' in the gradle file Also copied all 'data files' 3.04.00 version to 'tessdata' directory. I debugged Java portion of 'init' code it seems to be working fine, it's failing inside 'nativeside'.

Any suggestions what could be going wrong with my code. Here are few lines of code I am using to init

final String lang = "eng";
TessBaseAPI baseApi = new TessBaseAPI();
File externalDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
String externalDirPath = externalDir.getAbsolutePath() + "/";
flag = baseApi.init(externalDirPath, lang);
mahabudhi
  • 91
  • 1
  • 10
  • Yes I did get latest several times (even few mins back), it didn't work. Is there a way to turn on Debug logs from native side. – mahabudhi Jan 15 '16 at 17:43
  • Also I got latest code built aar file and started using it, thinking there is a mismatch between code and data files. This didn't work too. I am trying to look into native code. Is there a way I can see native logs on logcat? Now I have capability to insert my own code too as I am able to build aar file. – mahabudhi Jan 15 '16 at 18:17
  • Thank you, it's device related issue. Tried it on another tablet it works fine for me, same code. – mahabudhi Jan 15 '16 at 21:47
  • It's device related (Marshmallow) issue. Tried it on another tablet (KitKat) it works fine for me, same code. – mahabudhi Jan 15 '16 at 22:11

1 Answers1

2

The problem was not with tess-two, it was with my app, I deployed it on Marshmallow, it requires different way to get WRITE_EXTERNAL_STORAGE permission. I was not aware of it, now I fixed that issue my app is working fine.

mahabudhi
  • 91
  • 1
  • 10
  • Could you elaborate on what the fix was. I'm getting the same isssue targeting Marshmallow. – Mario Jan 30 '16 at 10:41
  • With M it's not only sufficient to put `` in Manifest, but you need to request permission explicity, something like `ActivityCompat.requestPermissions(activity,` `new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE,` `Manifest.permission.CAMERA }, WRITE_EXTERNAL_STORAGE_PERMISSION);` Check this for more information http://developer.android.com/training/permissions/requesting.html – mahabudhi Jan 31 '16 at 19:34
  • @mahabudhi I'm having the same issue in Marshmallow, even with the permission request you listed. On Lollipop things work fine, however. My app is explicitly asks the user for camera access when it is first installed but never asks for read/write permission. The app can take a picture from the camera or the gallery but when it is cropped for text recognition the app crashes because the image cannot be opened. – nocdib Jul 14 '16 at 04:32