Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android tesseract no text out at recognise() #11

Closed
scubess opened this issue Oct 20, 2019 · 11 comments
Closed

Android tesseract no text out at recognise() #11

scubess opened this issue Oct 20, 2019 · 11 comments

Comments

@scubess
Copy link

scubess commented Oct 20, 2019

Hi @rhardih ,

I compiled tesseract 4.0.0 for android and produce shared libraries using Building from one of your Android Docker file.

I wrote a simple JNI wrapper and using ndk-build with android.mk file, I build a shared library that goes into my application. I can see, tesseract has been initialised and can get the version 4.0.0 with no issue. I am seeing no crashes but at the same time, I can't see any text has been recognised or no error is thrown.

I followed the instructions and I am sure, I downloaded the right version of trained data file into tessdata folder. Even I tried with different versions of .traineddata, didn't make any difference.

To note, when I use tesseract 3.05, I can see the code runs with no issues. I can't understand what's going wrong here. I have been trying for days and I couldn't find the issue.

I tried to post this question in tesseract. Sadly, its been closed as they said they cant provide any help for throd party projects.

I attached the sample app with JNI wrapper please click the link for the sample android application

Environment: Tesseract
Tesseract Version: tesseract 4.0.0

Current Behavior:
No text recognised at in api->GetUTF8Text()

Expected Behavior:
returns recognised text from the image

Look forward yours help!

@rhardih
Copy link
Owner

rhardih commented Oct 20, 2019

Are you running the LSTM engine or the legacy one?

I remember something about the new LSTM engine possibly not working on Android due to being too memory demanding. I've only used the legacy engine myself.

This issue has a bit more info: rmtheis/tess-two#196

@scubess
Copy link
Author

scubess commented Oct 21, 2019

Hi @rhardih ,
thanks for reply. I haven't set the engine mode at all. I beleive it goes to default. I tried in the morning to set the engine mode to
apiTest->SetVariable("tessedit_ocr_engine_mode", "OEM_TESSERACT_ONLY");

It didn't made any difference.

@alexcohn
Copy link

Hi @scubess, it would be much easier to help you if you post the bitmap that is passed to OCREngineImp.recognition()

@scubess
Copy link
Author

scubess commented Oct 22, 2019

Hi @alexcohn ,
Thanks for helping me. Please find the attached image that i am sending for recognition and also i creating one via code in the sample app
testImage

@alexcohn
Copy link

Maybe I am missing something, but your bitmap should be 640x480, and here you post a PNG of size 1280x960 pixels. If by any chance this image is passed to tesseract with wrong size and/or format, it won't have a chance to find text there.

@scubess
Copy link
Author

scubess commented Oct 22, 2019

Hi @alexcohn,

Sorry, It's my fault. I didn't made it clear to you. The bitmap image I am passing is created via code in the sample app. But as you asked the image, I have another image which I created and load from assets folder. Tesseract didn't recognise both images. The one I sent to you is loading from Assets folder.

@alexcohn
Copy link

Exactly, so I thought, maybe the bitmap that is created via code is not good. With a png from assets, it's easier to debug the engine.

@scubess
Copy link
Author

scubess commented Oct 22, 2019

Hi @alexcohn ,
Just let you know, the info may be helpful. I have been trying to send bitmap images from Camera. The recognition works for v3.05 of Tesseract. But it's not working for tesseract 4.0.0. I put the code in the issue/test_from_file branch in the sample app.

Thanks again for looking into it.

EDITED: @alexcohn I made a change to load image from asset folder for you now

@scubess
Copy link
Author

scubess commented Oct 25, 2019

Hi @alexcohn @rhardih ,

When I build tesseract 4.1.0 and use 4.0.0 LSTM (tessdata_fast) models, it worked!

Thank you so much for your work & help!

@rhardih
Copy link
Owner

rhardih commented Oct 25, 2019

Hi @scubess, sorry for the late reply. Been a busy week. Good thing you got it to work. I've added an issue for bumping the default 4.x to be 4.1 here #12. Will get on it soon hopefully. 👍

@rhardih rhardih closed this as completed Oct 25, 2019
@scubess
Copy link
Author

scubess commented Oct 27, 2019

Thank you @rhardih

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants