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

tesseract 4 android build issue #875

Closed
romaderi opened this issue May 4, 2017 · 12 comments
Closed

tesseract 4 android build issue #875

romaderi opened this issue May 4, 2017 · 12 comments

Comments

@romaderi
Copy link

romaderi commented May 4, 2017

Hi I have juste replaced the jni\com_googlecode_tesseract_android\src in the tess two project with 4.0 tesseract src and try to compile it with ndkbuild. I'm facing an issue with the following error ...
[armeabi] Install : libjpgt.so => libs/armeabi/libjpgt.so
[armeabi] Install : liblept.so => libs/armeabi/liblept.so
[armeabi] Install : libpngt.so => libs/armeabi/libpngt.so
[armeabi] Compile++ thumb: tess <= lstm.cpp
jni/com_googlecode_tesseract_android/src/lstm/lstm.cpp:85:64: error: use of
undeclared identifier 'log2'
nf_ = type_ == NT_LSTM_SOFTMAX ? no_ : IntCastRounded(ceil(log2(no_)));
^
jni/com_googlecode_tesseract_android/src/lstm/lstm.cpp:183:31: error: use of
undeclared identifier 'log2'
nf_ = IntCastRounded(ceil(log2(no_)));
^
2 errors generated.
make: *** [obj/local/armeabi/objs/tess/src/lstm/lstm.o] Error 1

Any idea ?

@stweil
Copy link
Contributor

stweil commented May 4, 2017

It looks like log2 is not provided by Android. See this discussion which also includes valid solutions.

Tesseract already uses its own log2 for Android in wordrec/language_model.cpp.

@raulcorreia1
Copy link

Hi romaderi, I am also trying to build tesseract 4 using the base of tess-two, to prevent the log2 issue I think you need to add the code below before the namespace in lstm.cpp and weightmatrix.cpp:

#if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(ANDROID)
double log2(double n) {
  return log(n) / log(2.0);
}
#endif  // _MSC_VER

Now after doing that I found some other errors:

Error:error: assigning to 'PROGRESS_FUNC' (aka 'bool (*)(int, int, int, int, int)') from incompatible type 'bool (void *, int, int, int, int, int)': different number of parameters (5 vs 6)

Not sure how to solve this one...

@avestnik
Copy link

hi! I faced the same problem, was able to fix it inserting log2() implementation into lstm.cpp and weightmatrix.cpp. I guess it would be nice if source code maintainers fix it in upstream

@Shreeshrii
Copy link
Collaborator

@stweil
Copy link
Contributor

stweil commented Feb 28, 2018

Sure. The easy solution would use the code shown above, but I want to replace the log function by faster pure integer calculations here (which needs a little bit more time to implement it).

@Shreeshrii
Copy link
Collaborator

@stweil Would it make sense to implement the easy solution now and revert it when you replace the log function later?

@amitdo
Copy link
Collaborator

amitdo commented Feb 28, 2018

Related: android/ndk#82

@stweil
Copy link
Contributor

stweil commented Mar 1, 2018

The issue is addressed by pull request #1353.

@rezaee
Copy link

rezaee commented Mar 14, 2018

Hi there,
May you tell me where can I get the tesseract-4 source and which folder exactly should replace with which one?
I am newbie and want to use tesseract-4 on my Android applications!

I did git clone git://github.com/tesseract-ocr/tesseract.git but don't know should replace which folder with jni\com_googlecode_tesseract_android\src inside tess-two folder?

@amitdo
Copy link
Collaborator

amitdo commented Aug 31, 2018

Android has log2() now.
https://developer.android.com/ndk/guides/cpp-support#libc

@stweil
Copy link
Contributor

stweil commented Sep 9, 2018

That's good. And the Tesseract code has code which supports older installations without log2 since some time. @romaderi, could you please close this issue, or do you think there is still a problem?

@zdenop zdenop closed this as completed Sep 28, 2018
@amitdo
Copy link
Collaborator

amitdo commented Jan 14, 2021

I think the log2() for android is obsolete.

The older NDKs that needed that custom code are no longer supported by Google. AFAIK, new NDKs can be used to build apps for old android releases.

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

8 participants