Git Product home page Git Product logo

Comments (16)

zdenop avatar zdenop commented on May 22, 2024

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.

jonashaag avatar jonashaag commented on May 22, 2024

On macOS, your Linux commands reproduce the infinite loop

from tesseract.

zdenop avatar zdenop commented on May 22, 2024

@jonashaag : how did you installed tesseract?

@stweil : Can you have a look at this?

from tesseract.

stweil avatar stweil commented on May 22, 2024

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.

stweil avatar stweil commented on May 22, 2024

@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.

jonashaag avatar jonashaag commented on May 22, 2024

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.

jonashaag avatar jonashaag commented on May 22, 2024

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.

stweil avatar stweil commented on May 22, 2024

Conda links:

I am still searching for a description of the build process which was used for the Conda Tesseract package.

from tesseract.

jonashaag avatar jonashaag commented on May 22, 2024

It is here:

from tesseract.

stweil avatar stweil commented on May 22, 2024

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 the tessdata 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.

jonashaag avatar jonashaag commented on May 22, 2024

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.

stweil avatar stweil commented on May 22, 2024

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.

stweil avatar stweil commented on May 22, 2024

Pull request #4239 should fix this issue.

from tesseract.

jonashaag avatar jonashaag commented on May 22, 2024

Fantastic! Thanks a million!

from tesseract.

stweil avatar stweil commented on May 22, 2024

@jonashaag, I am sorry, but my patch does not work. I'll try a different fix tomorrow.

from tesseract.

stweil avatar stweil commented on May 22, 2024

Pull request #4240 has a different fix which I now tested successfully on Linux and on macOS.

from tesseract.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.