issue #1393: Android NDK: LOCAL_MODULE definition in jni/Android.mk must not contain space

97 views
Skip to first unread message

Zdenko Podobny

unread,
May 25, 2019, 4:49:32 AM5/25/19
to tesser...@googlegroups.com
Hi all,

this issue[1] is open for quite a while: I know there are people who successfully build tesseract for android. Can somebody experienced (at android builds) have a look at this and provide:
  1. fix for this issue
  2. step by step tutorial how to build tesseract for android
I would like to solve it for next tesseract 4.1 release... 


Zdenko

JB Data31

unread,
Jun 21, 2019, 10:21:31 AM6/21/19
to tesser...@googlegroups.com
Hi,

I achieve the Androïd build of tesseract (June src git clone) and test on device.
I use the post [tesseract-ocr] Re: Recognition of "5" instead of "S" as a testcase, see attached screenshot.

Tesseract Androïd build is not a trivial way, NDK struggle as an not proper tutorial to pass.

@JBΔ


--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/CAJbzG8yS5ZRgZ-O%3DhHF4eBhHDeePRbNeMDQEJ6EHUpZGp05o5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
2019_06_17_08.16.57-0.jpg

Zdenko Podobny

unread,
Jun 24, 2019, 4:15:21 AM6/24/19
to tesser...@googlegroups.com
Thanks!  Can you write some tutorial, how to make static android build?

I tried shared build on windows (but I did not test it on android device - no time to learn this ;-) ), and it looks quite easy with cmake:
  1. Download android-ndk-r20-windows-x86_64.zip (https://developer.android.com/ndk/downloads/)
  2. Build and install leptonica (no other dependency)
  3. "Finetune" cmake option for tesseract and build it...
Of course I understand that building static tesseract library including dependencies is much more difficult, so maybe documenting your progress could be useful for a lot of people.


Zdenko


pi 21. 6. 2019 o 16:21 JB Data31 <jbda...@gmail.com> napísal(a):

Alex Cohn

unread,
Jun 25, 2019, 4:18:48 PM6/25/19
to tesseract-ocr
What kind of static build do you expect? Android apps need a shared library to work, but still it may be possible to build an executable binary that will be statically linked (i.e. no shared libs to load).

BR,
Alex Cohn


On Monday, June 24, 2019 at 11:15:21 AM UTC+3, zdenop wrote:
Thanks!  Can you write some tutorial, how to make static android build?

I tried shared build on windows (but I did not test it on android device - no time to learn this ;-) ), and it looks quite easy with cmake:
  1. Download android-ndk-r20-windows-x86_64.zip (https://developer.android.com/ndk/downloads/)
  2. Build and install leptonica (no other dependency)
  3. "Finetune" cmake option for tesseract and build it...
Of course I understand that building static tesseract library including dependencies is much more difficult, so maybe documenting your progress could be useful for a lot of people.


Zdenko


pi 21. 6. 2019 o 16:21 JB Data31 <jbda...@gmail.com> napísal(a):
Hi,

I achieve the Androïd build of tesseract (June src git clone) and test on device.
I use the post [tesseract-ocr] Re: Recognition of "5" instead of "S" as a testcase, see attached screenshot.

Tesseract Androïd build is not a trivial way, NDK struggle as an not proper tutorial to pass.

@JBΔ


Le sam. 25 mai 2019 à 08:49, Zdenko Podobny <zde...@gmail.com> a écrit :
Hi all,

this issue[1] is open for quite a while: I know there are people who successfully build tesseract for android. Can somebody experienced (at android builds) have a look at this and provide:
  1. fix for this issue
  2. step by step tutorial how to build tesseract for android
I would like to solve it for next tesseract 4.1 release... 


Zdenko

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesser...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesser...@googlegroups.com.

Zdenko Podobny

unread,
Jun 26, 2019, 3:18:27 AM6/26/19
to tesser...@googlegroups.com
I do not expect anything ;-) - but based on JB discussion on
android-ndk he tried to get to get a static arm64 binary. I
understand he was successful, so sharing how to achieve it, would be
nice.

Zdenko

ut 25. 6. 2019 o 22:18 Alex Cohn <sasha...@gmail.com> napísal(a):
> To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
> To post to this group, send email to tesser...@googlegroups.com.
> Visit this group at https://groups.google.com/group/tesseract-ocr.
> To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/88d08215-b33b-4071-bd90-dff713207c91%40googlegroups.com.

JB Data31

unread,
Jul 1, 2019, 6:13:35 AM7/1/19
to tesseract-ocr
As a first step of a tesseract androïd use, I try/achieve the build of tesseract and execute with a shell on my device. That's not a stock way to execute app on Androïd, but very instructive.
According NDK guides, § C++ STL support, the recommendation is to build static. So do I.

Back to NDK user group to get forward.

JB Data31

unread,
Sep 3, 2019, 6:16:28 AM9/3/19
to tesser...@googlegroups.com
I achieve Tesseract Androïd testing.
Cause Androïd target can't be limited to libs cross compiling, I roadact this way:
  • Data.
I use the post [tesseract-ocr] Re: Recognition of "5" instead of "S" as a testcase, interesting cause has a own traineddata file.
  • Build a static binary (Screenshot #1).
As a first step of testing, it's a kind of challenge cause execute app on device with a shell is not a common way to do.
Happy to see someone else succeed, checkered flag is a device screenshot.
  • Analyse and test a playstore app : textfairy
An impressive dev.
  • Build an App (Screenshot #2) : MinOCR
If you install on device (my is Android 7), do the proto howto : click Init, click OCR-1, click Init, click OCR-0.
APK shares 2 differents release of Tesseract native libs (OCR-1: 4.1, OCR-0: 5.0) and wrappers, that's not a proper way to do, but fun (when pass) to debug on device.

Focus on Android target I test two ways to pass

1/ The A-Z (OCR-0 on MinOCR)
  1. Get 3-parts libs and tesseract src from git
  2. Install Android NDK and many more
  3. Discover proper parameters of configures
  4. Builds native libs
  5. Dev a Java wrapper
  6. Put all together in an APK and debug.
2/ The All-In-One (OCR-1 on MinOCR)
So you go to "the put all together in APK" state and avoid "debug" step.
  1. Add a few lepto and tess jars to your project.
  2. Load libs and use Leptonica and Tesseract API to OCR text.
System.loadLibrary(_context, "lept");
System.loadLibrary(_context, "jnilept");
System.loadLibrary(_context, "tesseract");
System.loadLibrary(_context, "jnitesseract");
...
TessBaseAPI api = new TessBaseAPI();
PIX image = lept.pixRead(imagePath);
api.SetImage(image);
outText = api.GetUTF8Text();

There's a current limit to this solution: the Android API release, downloads have been built to API21, but I init a pull request, can improve.

@JBΔ



Le sam. 25 mai 2019 à 08:49, Zdenko Podobny <zde...@gmail.com> a écrit :
--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
tesseract_20190617.jpg
MinOCR-0.gif

Alex Cohn

unread,
Sep 12, 2019, 4:25:56 PM9/12/19
to tesseract-ocr
On Monday, July 1, 2019 at 1:13:35 PM UTC+3, JB Data31 wrote:
As a first step of a tesseract androïd use, I try/achieve the build of tesseract and execute with a shell on my device. That's not a stock way to execute app on Androïd, but very instructive.
According NDK guides, § C++ STL support, the recommendation is to build static. So do I.

Oh, you refer to c++_static as opposed to using libc++_shared.so. You are right it's preferable.
BR
Alex

 
Reply all
Reply to author
Forward
0 new messages