Comments (16)
Can you please exactly describe how to reproduce the problem?
How did you install tesseract?
I do not have macOS, but on Windows, I got this result:
> set TESSDATA_PREFIX=""
> tesseract --list-langs
List of available languages in """/" (0):
>set TESSDATA_PREFIX=
>tesseract --list-langs
List of available languages in "./" (1):
Downloads/dotslayer
On the Linux I got this result:
$ export TESSDATA_PREFIX=""
$ tesseract --list-langs
List of available languages in "/usr/share/tesseract-ocr/5/tessdata/" (2):
eng
osd
from tesseract.
On macOS, your Linux commands reproduce the infinite loop
from tesseract.
@jonashaag : how did you installed tesseract?
@stweil : Can you have a look at this?
from tesseract.
I don't get an infinite loop on macOS (installed with Homebrew). An empty TESSDATA_PREFIX
is handled like an unset one:
% tesseract --list-langs|head -3
List of available languages in "/opt/homebrew/share/tessdata/" (682):
Fraktur
Greek
% TESSDATA_PREFIX= tesseract --list-langs|head -3
List of available languages in "/opt/homebrew/share/tessdata/" (682):
Fraktur
Greek
from tesseract.
@jonashaag, addAvailableLanguages
starts searching for Tesseract model files at a well defined start location and is called recursively only if it finds a directory. Unless you have a cyclic directory structure, there won't be an infinite recursion. macOS and Linux use the same code.
Can you see the arguments of the stat64
calls? Where does the search start? Maybe there are simply a lot of files and directories below your start location. If there is really an endless recursion, it will have a first directory entry which will occur again and again.
from tesseract.
Aha, interesting, the Homebrew version works fine. The conda-forge version that I've been using doesn't.
Output from macOS's fs_usage
:
11:50:07.100355 open F=3 (R_____N____X) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/.pixi/envs/default/share/tessdata 0.000020 tesseract.1362835
11:50:07.100364 fstatfs64 F=3 0.000002 tesseract.1362835
11:50:07.100439 getdirentries64 F=3 B=0x14d0 0.000074 tesseract.1362835
11:50:07.100443 stat64 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/.pixi/envs/default/share/tessdata 0.000003 tesseract.1362835
11:50:07.100450 open F=4 (R_____N____X) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/.pixi/envs/default/share/tessdata 0.000007 tesseract.1362835
11:50:07.100451 fstatfs64 F=4 0.000001 tesseract.1362835
11:50:07.100501 getdirentries64 F=4 B=0x14d0 0.000050 tesseract.1362835
11:50:07.100503 stat64 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/.pixi/envs/default/share/tessdata 0.000002 tesseract.1362835
11:50:07.100509 open F=5 (R_____N____X) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/.pixi/envs/default/share/tessdata 0.000006 tesseract.1362835
11:50:07.100510 fstatfs64 F=5 0.000001 tesseract.1362835
11:50:07.100559 getdirentries64 F=5 B=0x14d0 0.000049 tesseract.1362835
11:50:07.100561 stat64 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/.pixi/envs/default/share/tessdata 0.000002 tesseract.1362835
[... repeated indefinitely ...]
from tesseract.
There are no symlinks in .pixi/envs/default/share/tessdata
or any of its children.
$ file --no-dereference .pixi/envs/default/share/tessdata/** | grep sym
[empty]
from tesseract.
Conda links:
I am still searching for a description of the build process which was used for the Conda Tesseract package.
from tesseract.
It is here:
- https://github.com/conda-forge/tesseract-feedstock/blob/main/recipe/build.sh
- https://github.com/conda-forge/tesseract-feedstock/blob/main/recipe/meta.yaml
from tesseract.
Thanks. I could build it locally, and the result works fine. It looks like the error is in libtesseract.5.dylib
which is not surprising because that library contains the function addAvailableLanguages
.
In my tests with the conda-forge binary I get some more strange results:
tesseract --list-langs
works if thetessdata
directory is empty.- It also terminates if there is a single entry (file or directy) below
tessdata
, but fails to report if that file is a model file. - It runs endless if there are two or more entries below
tessdata
.
I cannot explain that strange results with the Tesseract code, and debugging without debug symbols is rather time consuming. Therefore I suggest to report the issue to conda-forge.
from tesseract.
I think it is related to Conda's prefix replacement. The prefix ends up being empty or something like that. I will build a package with debug symbols/prints and check what's going on.
from tesseract.
That's a good hint which helped me find the root of the problem.
Patching TESSDATA_PREFIX in the compiled library does currently not work for Tesseract because that string is assigned to std::string datadir
in CCUtil::main_setup
. This datadir
gets a different string value after the patch, but its length is not patched and still has the value of the unpatched string. Therefore datadir
won't get the required terminating '/' character.
This is not restricted to installations on macOS. Installations with Conda on Linux will have the same problem.
I think there is a simple fix which I will try later.
from tesseract.
Pull request #4239 should fix this issue.
from tesseract.
Fantastic! Thanks a million!
from tesseract.
@jonashaag, I am sorry, but my patch does not work. I'll try a different fix tomorrow.
from tesseract.
Pull request #4240 has a different fix which I now tested successfully on Linux and on macOS.
from tesseract.
Related Issues (20)
- unicharset_extractor segfault HOT 31
- Please add the API call to translate the language code to the full language name HOT 3
- Warning: LSTMTrainer deserialized an LSTMRecognizer! Error, data/eng/eng_num_vert.lstm is an integer (fast) model, cannot continue training HOT 7
- Add the NN for a 'random' ASCII language HOT 1
- "min_characters_to_try" parameter does not work HOT 2
- phonetic symbols and special characters HOT 1
- inform where we can find tesseract.exe HOT 2
- Native Crash in otsuthr.cpp HOT 2
- CI: vcpkg failure due to missing xz tarball HOT 4
- link error LNK1120 with text2image.exe
- Mac m1, not able to compile HOT 2
- OCR of Indian Currency Sign " ₹" HOT 2
- please support linux binary , like fzf HOT 1
- SW Pipeline for Ubuntu failed HOT 2
- text2image needs pango_training.so which in turn is not installed HOT 7
- Can not read input file in /tmp HOT 3
- Tesseract can not recognize grey text in black background HOT 1
- Multiple language detection within an image
- Floating-point exception (SIGFPE) due to out-of-range input to asinf in Wordrec::angle_change HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tesseract.