Comments (20)
My stab in the dark at any answer is that, for some reason, the OpenCL API or ABI different from Tesseract is expecting as declared in header files.
The malloc error occurs because (openclwrapper.cpp:674) in
size_t numDevices;
clGetProgramInfo(... sizeof(numDevices), &numDevices, ...):
The call to clGetProgramInfo
writes the correct value to the lower 32-bit of numDevices, but leaves uninit'ed garbage in the upper 32-bits. But even if this is correct, other OpenCL calls generated errors:
[DS] Device: "Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz" (OpenCL) evaluation...
OpenCL error code is -54 at when clEnqueueNDRangeKernel .
OpenCL error code is -54 at when clEnqueueNDRangeKernel kernel_HistogramRectAllChannels .
OpenCL error code is -54 at when clEnqueueNDRangeKernel kernel_HistogramRectAllChannelsReduction .
OpenCL error code is -54 at when clEnqueueNDRangeKernel kernel_ThresholdRectToPix .
I'd be happy to investigate further if someone can point me in the right direction.
from tesseract.
Can you check 0c3c3ea ?
from tesseract.
I currently get configure: error: Required OpenCL library not found!
(associated config.log). With 3.04.00 I can compile (and seemingly use) Tesseract configured with --enable-opencl
(associated config.log for 3.04.00).
from tesseract.
@zdenop I got the same error as @ryanfb.
The consensus is that AC_CHECK_LIB doesn't play nicely with -framework
. Instead you can introduce a new macro, or just bypass the check on OS X. The nice thing about frameworks is that they are internally consistent, where you never what kind of crazy library-header mismatches you might find on a *nix box.
https://lists.apple.com/archives/unix-porting/2009/Jan/msg00026.html
from tesseract.
@zdenop I disabled the AC_CHECK_LIB(OpenCL) and replaced it with have_opencl_lib=true
. That got me to a new error:
configure: error: conditional "OPENMP" was never defined.
Usually this means the macro was only invoked conditionally.
To repair that I added the required conditional:
@@ -168,12 +168,14 @@ if test "$enable_embedded" = "yes"; then
fi
# check whether to build OpenMP support
-AC_OPENMP
+#AC_OPENMP
AS_IF([test "x$OPENMP_CFLAGS" != "x"],
AM_CONDITIONAL([OPENMP], test "x$OPENMP_CFLAGS" != "x")
AC_SUBST(AM_CPPFLAGS,"$OPENMP_CXXFLAGS")
AC_DEFINE([OPENMP], [], [Defined when compiled with OpenMP support])
)
+AM_CONDITIONAL([OPENMP], test "x$OPENMP_CFLAGS" != "x")
+
After autoreconf -fvi
I had a working ./configure.
...and make failed with several errors of this form:
openclwrapper.cpp:3401:33: error: non-constant-expression cannot be narrowed
from type 'int' to 'size_t' (aka 'unsigned long') in initializer list
[-Wc++11-narrowing]
size_t local_work_size[] = {block_size};
^~~~~~~~~~
from tesseract.
@jbarlow83: configure issues should be fixed. Which version of compiler you use?
from tesseract.
The line if test $host_os != Darwin; then
does not work because $host_os
is darwin14.5.0
. If this test is bypassed, configure works and make fails with a new error.
In file included from openclwrapper.cpp:11:
./openclwrapper.h:2:10: fatal error: 'allheaders.h' file not found
#include "allheaders.h"
That error occurs even though I am running env LIBLEPT_HEADERSDIR=/usr/local/include/leptonica ./configure --enable-opencl
, the location of allheaders.h. Using CC=gcc-5 (homebrew gcc, not clang) also gives the header error.
Here is clang.
$ clang --version
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
from tesseract.
@jbarlow83: Thanks. Unfortunatelly I do not have Mac, so I can just guess what could work :-(.
If you change test to if test $host_os != darwin; then
will it help? Or to if test $host_os != darwin*; then
?
regading leptonica: Try to change line if it helps:
LIBLEPT_HEADERSDIR="/usr/local/include /usr/include /opt/local/include/leptonica"
to
LIBLEPT_HEADERSDIR="/usr/local/include /usr/include /opt/local/include/"
from tesseract.
#87 is also required. So I got to compile and apparently run successful OpenCL tests in which it selected my graphics card... but the OCR output was garbage. For example, if I had it generate a PDF, it still produced a valid PDF containing the input image, but the OCR text and its positioning was meaningless.
If I rebuild the same source with OpenCL my test file was processed correctly.
$ /opt/tesseract-opencl/bin/tesseract -l eng ~/tests/resources/LinnSequencer.jpg out
Tesseract Open Source OCR Engine v3.05.00dev with Leptonica
[DS] Profile file not available (tesseract_opencl_profile_devices.dat); performing profiling.
[DS] Device: "Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz" (OpenCL) evaluation...
OpenCL error code is -54 at when clEnqueueNDRangeKernel .
OpenCL error code is -54 at when clEnqueueNDRangeKernel kernel_HistogramRectAllChannels .
OpenCL error code is -54 at when clEnqueueNDRangeKernel kernel_HistogramRectAllChannelsReduction .
OpenCL error code is -54 at when clEnqueueNDRangeKernel kernel_ThresholdRectToPix .
Setting return value to -1
[DS] Device: "Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz" (OpenCL) evaluated
[DS] composeRGBPixel: 0.000132 (w=1.2)
[DS] HistogramRect: 340282346638528859811704183484516925440.000000 (w=2.4)
[DS] ThresholdRectToPix: 340282346638528859811704183484516925440.000000 (w=4.5)
[DS] getLineMasksMorph: 0.004014 (w=5.0)
[DS] Score: inf
[DS] Device: "GeForce GT 755M" (OpenCL) evaluation...
[DS] Device: "GeForce GT 755M" (OpenCL) evaluated
[DS] composeRGBPixel: 0.044892 (w=1.2)
[DS] HistogramRect: 0.026128 (w=2.4)
[DS] ThresholdRectToPix: 0.053928 (w=4.5)
[DS] getLineMasksMorph: 0.025597 (w=5.0)
[DS] Score: 0.487237
[DS] Device: "(null)" (Native) evaluation...
[DS] Device: "(null)" (Native) evaluated
[DS] composeRGBPixel: 0.019921 (w=1.2)
[DS] HistogramRect: 0.063245 (w=2.4)
[DS] ThresholdRectToPix: 0.034175 (w=4.5)
[DS] getLineMasksMorph: 0.124600 (w=5.0)
[DS] Score: 0.952483
[DS] Scores written to file (tesseract_opencl_profile_devices.dat).
[DS] Device[1] 1:Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz score is inf
[DS] Device[2] 1:GeForce GT 755M score is 0.487237
[DS] Device[3] 0:(null) score is 0.952483
[DS] Selected Device[2]: "GeForce GT 755M" (OpenCL)
Warning in pixReadMemJpeg: work-around: writing to a temp file
from tesseract.
@zdenop Our patches to date have fixed the build, but tesseract with OpenCL on Mac outputs gibberish as the OCR results (on an image that passes normal OCR). Both the perceived position of text and output text are corrupted. However, a blank image is correctly interpreted as a being blank - for example, tesseract can properly render a blank PDF file. I take this to mean somewhere OpenCL is distorting or corrupting the input during processing.
How I can test it to narrow down where the error actually occurs?
from tesseract.
AFAIK they should work on this. Did you get wrong result if you use binarized (2 colors) (tif?) image?
from tesseract.
Image I used was:
https://en.wikipedia.org/wiki/LinnSequencer#/media/File:LinnSequencer_hardware_MIDI_sequencer_brochure_page_2_300dpi.jpg
Although it appears to be grayscale it looks like it's formatted as true color. Output is:
Tesseract Open Source OCR Engine v3.05.00dev with Leptonica
[DS] Profile read from file (tesseract_opencl_profile_devices.dat).
[DS] Device[1] 1:Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz score is inf
[DS] Device[2] 1:GeForce GT 755M score is 0.487237
[DS] Device[3] 0:(null) score is 0.952483
[DS] Selected Device[2]: "GeForce GT 755M" (OpenCL)
Warning in pixReadMemJpeg: work-around: writing to a temp file
OSD: Weak margin (0.53), horiz textlines, not CJK: Don't rotate.
I converted that to a 1-bit TIFF using ImageMagick. That produced no OCR output and some errors:
[snipped common header]
Page 1
OSD: Weak margin (0.17), horiz textlines, not CJK: Don't rotate.
Error in boxClipToRectangle: box outside rectangle
Error in pixScanForForeground: invalid box
Error in boxClipToRectangle: box outside rectangle
Error in pixScanForForeground: invalid box
Error in boxClipToRectangle: box outside rectangle
Error in pixScanForForeground: invalid box
Error in boxClipToRectangle: box outside rectangle
Error in pixScanForForeground: invalid box
Error in boxClipToRectangle: box outside rectangle
Error in pixScanForForeground: invalid box
Error in boxClipToRectangle: box outside rectangle
Error in pixScanForForeground: invalid box
Error in boxClipToRectangle: box outside rectangle
Error in pixScanForForeground: invalid box
Error in boxClipToRectangle: box outside rectangle
Error in pixScanForForeground: invalid box
Warning in pixGenerateCIData: pixs has cmap; using flate encoding
Warning in pixReadMemTiffCl: tiff page 58428720 not found
In both cases, I did output to PDF, and the PDF is formatted correct. The OCR is nonsense. When output to plain text, the OCR is also nonsense.
If Tesseract is built without OpenCL the same image works fine for OCR.
from tesseract.
I tried both master and 3.04.00 with --enable-opencl
on Ubuntu with Catalyst 15.7 and for my two devices (FX8120 and R9 285) the OCR also outputs a .txt but the content is only empty lines and some wrong characters. Forcing to run without opencl achieves the correct output.
When running with OpenCL on FX8120 there are no warnings or errors during execution, but there are some warnings as tiff page not found
and box outside rectangle
on R9 285. In the end, the (wrong) output is the same for any of them.
from tesseract.
With OpenCL-enabled HEAD on OS X, I also get garbage for @jbarlow83's test image.
However if I convert PDFs to TIFF in the way I usually do for OCR with Tesseract, I can get text with OpenCL-enabled HEAD (the BW PDF for this book in this example):
convert -density 300 aesopsfables00mclo_bw.pdf -type Grayscale -compress lzw -background white +matte -depth 32 page_%05d.tif
Then OCR with e.g. for i in page_*.tif; do tesseract $i $(basename $i .tif); done
works fine and produces text (in both text and PDF output modes). This also seems to work for multipage TIFFs (just convert without the %05d
in the output filename), however, if I try to process a multipage TIFF during the initial OpenCL profiling run, Tesseract always crashes with a SIGABRT after the first page.
Another thing I notice though is that I also get a score of inf
for my CPU on OpenCL, is this a bug that needs to be fixed in the HistogramRect
/ThresholdRectToPix
evaluations?
from tesseract.
I tried tesseract -c tessedit_write_images=1 ...
and got the following result. The image has the same dimensions as the input image and there is a visual correspondence of sorts between the images, but it's very mangled. First image is input, second is "tessinput.tif" after Tesseract's mangling.
@zdenop: If a read and write pointer were strobing the data by different amounts you'd get this sort of thing. This really looks it a single increment somewhere is the wrong size and should be an easy fix for someone who knew where to look in the code base (i.e. not me).
from tesseract.
Yep, I have the same problem. Try resizing your image to powers of 2. Actually, just resize the canvas, leave the text part unchanged.You could do it with ImageMagick convert, or any image editor like Photoshop. Probably you only need to size the width to power of 2, I didn't test that, but it looks like the pitch is being miscalculated with non-power of two sized images.
from tesseract.
Oh...didn't mention it, but I get exactly the same output as you. Bring the distorted image up in PhotoShop, Select Filter->Distort->Shear and shear top left to bottom right with Wraparound selected. Do that 2-4 times and the text will magically appear.
from tesseract.
Look at Issue #124
from tesseract.
Please check master branch or commits f46dfdc and 5db7602.
from tesseract.
Hi folks,
i have a similar problems with the garbage output, when i enable opencl. I have checked out the current master revision (bd45b3a). also i get the mangled image with tesseract -c tessedit_write_images=1 ...
command too.
The OS is Debian 64bit.
My Settings are:
tesseract 4.00.00alpha
leptonica-1.74.1
libjpeg 6b (libjpeg-turbo 1.3.1) : libpng 1.2.50 : libtiff 4.0.3 : zlib 1.2.8
OpenCL info:
Found 1 platform(s).
Platform 1 name: NVIDIA CUDA.
Version: OpenCL 1.1 CUDA 6.5.51.
Found 1 device(s).
Device 1 name: GeForce GTX 750 Ti.
Found AVX
Found SSE
the console output is:
Tesseract Open Source OCR Engine v4.00.00alpha with Leptonica
OSD: Weak margin (1.36) for 292 blob text block, but using orientation anyway: 0
[DS] Profile read from file (tesseract_opencl_profile_devices.dat).
[DS] Device[1] 1:GeForce GTX 750 Ti score is 0.128314
[DS] Device[2] 0:(null) score is 0.917442
[DS] Selected Device[1]: "GeForce GTX 750 Ti" (OpenCL)
Tesseract Open Source OCR Engine v4.00.00alpha with Leptonica
OSD: Weak margin (5.65) for 486 blob text block, but using orientation anyway: 3
Error in boxClipToRectangle: box outside rectangle
Error in pixScanForForeground: invalid box
My Question is: do i have a malconfigurated system or is it a bug?
from tesseract.
Related Issues (20)
- multithreaded tesseract causes Linux crash HOT 5
- Linker Error for tesseract53.lib HOT 1
- Add redirect function HOT 1
- Add ICD Codes in english trained Data HOT 2
- Some CI jobs (GitHub Actions) are failing HOT 10
- uuencode-generated text is OCRed with many mistakes HOT 2
- Error! The command "tesseract" was not found. HOT 2
- Error! The command "tesseract" was not found
- 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 1
- 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
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.