-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Support image width and height larger than 32767 #3435
base: main
Are you sure you want to change the base?
Conversation
Please don't merge until these changes were better tested. |
The modifications here allow processing of large images which fixes issue #3184. I only tested the example in that issue and did not run performance tests or measure the increased memory usage. |
Known issues: code setting x / y / width / height to |
|
I wonder about the impact on regular size images. How much more memory (in percents) will be consumed with this patch? |
I don't have numbers up to now. |
This pull request introduces 3 alerts when merging eb8f13b into 93348a8 - view on LGTM.com new alerts:
|
You changed int16->int32 a lot. |
Yes, the current Tesseract code uses I considered using a typedef, but don't think that there will be a future change for which a typedef would help. What kind of possible change do you think of? |
I agree, this may be subtle. |
9fc3685
to
5dbd736
Compare
|
What standards? |
ISO C, see https://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html. |
Should we make support for large images an optional feature in release 5.0.0 by adding a configure option, for example |
Or just ignore them. |
If you choose to do it for 5.0.0, I suggest to add to the help message that explains this option:
and in a comment in the code itself:
|
2e508b3
to
0b681f9
Compare
Most parts of the initial pull requests are now in |
@stweil Hi, Is this feat merged to main branched? Why i just see this not changed at the tag 5.3.0 source code : |
No, it isn't merged. This pull request is still a draft. |
it seems some years already, what‘s the reason? |
… input images. Available to both userland and tesseract internal code, these can be used to report & early fail images which are too large to fit in memory. Some very lenient defaults are used for the memory pressure allowance (1.5 GByte for 32bit builds, 64GByte for 64bit builds) but this can be tweaked to your liking and local machine shop via Tesseract Global Variable `allowed_image_memory_capacity` (DOUBLE type). NOTE: the allowance limit can be effectively removed by setting this variable to an 'insane' value, e.g. `1.0e30`. HOWEVER, the CheckAndReportIfImageTooLarge() API will still fire for images with either width or high dimension >= TDIMENSION_MAX, which in the default built is the classic INT16_MAX (32767px); when compiled with defined(LARGE_IMAGES), then the width/height limit is raised to 24bit i.e. ~ 16.7 Mpx, which would then tolerate images smaller than 16777216 x 16777216px. (This latter part is a work-in-progress.) Related: - tesseract-ocr#3184 - tesseract-ocr#3885 - tesseract-ocr#3435 (pullreq by @stweil -- WIP) # Conflicts: # src/api/baseapi.cpp # src/ccmain/tesseractclass.h # src/ccmain/thresholder.cpp # src/ccutil/params.h # src/textord/tordmain.cpp
… input images. Available to both userland and tesseract internal code, these can be used to report & early fail images which are too large to fit in memory. Some very lenient defaults are used for the memory pressure allowance (1.5 GByte for 32bit builds, 64GByte for 64bit builds) but this can be tweaked to your liking and local machine shop via Tesseract Global Variable `allowed_image_memory_capacity` (DOUBLE type). NOTE: the allowance limit can be effectively removed by setting this variable to an 'insane' value, e.g. `1.0e30`. HOWEVER, the CheckAndReportIfImageTooLarge() API will still fire for images with either width or high dimension >= TDIMENSION_MAX, which in the default built is the classic INT16_MAX (32767px); when compiled with defined(LARGE_IMAGES), then the width/height limit is raised to 24bit i.e. ~ 16.7 Mpx, which would then tolerate images smaller than 16777216 x 16777216px. (This latter part is a work-in-progress.) Related: - tesseract-ocr#3184 - tesseract-ocr#3885 - tesseract-ocr#3435 (pullreq by @stweil -- WIP)
Builds now can define LARGE_IMAGES to use 32 bit for image dimensions instead of 16 bit. Signed-off-by: Stefan Weil <[email protected]>
Signed-off-by: Stefan Weil [email protected]