Why tesseract gives different results on almost same pictures? - tesseract

Screenshots have been captured on two windows 10 machines with the same tesseract (I just copied tesseract folder from one to another machine). I noticed that every 2 corresponding pixels in images differ in 1-2 (I have no idea why they are different. Both have been made using python pillow's ImageGrab module. Windows color settings are identical). I tried to normalize images (https://stackoverflow.com/a/7422584/13635865), but with other images it doesn't work. Tesseract version:
tesseract v5.1.0.20220510
leptonica-1.78.0
libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.3) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.0
Found AVX2
Found AVX
Found FMA
Found SSE4.1
Found libarchive 3.5.0 zlib/1.2.11 liblzma/5.2.3 bz2lib/1.0.6 liblz4/1.7.5 libzstd/1.4.5
Found libcurl/7.77.0-DEV Schannel zlib/1.2.11 zstd/1.4.5 libidn2/2.0.4 nghttp2/1.31.0
cmd: tesseract <good/bad>.png stdout -l rusResult with good.png: Карта получателяResult with bad.png: ЕВЕGood image: https://ibb.co/bHLtP67Bad image: https://ibb.co/G3FT2cT
Why there is such a big difference in tesseract results on almost the same images?

Can not reproduce problem:
>tesseract good.png - -l rus
Карта получателя
>tesseract bad.png - -l rus
Карта получателя
>tesseract -v
tesseract 5.1.0-70-g0df5
leptonica-1.83.0 (Jun 24 2022, 17:48:50) [MSC v.1929 LIB Release x64]
libgif 5.2.1 : libjpeg 6b (libjpeg-turbo 2.0.91) : libpng 1.6.37 : libtiff 4.4.0 : zlib 1.2.12 : libwebp 1.2.2 : libopenjp2 2.5.0
Found AVX2
Found AVX
Found FMA
Found SSE4.1
Found libarchive 3.5.1 zlib/1.2.11 liblzma/5.2.4 bz2lib/1.0.6 libzstd/1.4.9
Found libcurl/7.75.0 zlib/1.2.12 libssh2/1.10.1_DEV

Related

Which version of arm gnu toolchain should I use to run on Rpi 4B?

I want to use Raspberry Pi 4B to compile code for stm32. Therefore I download the "AArch64 Linux hosted cross toolchains" version of arm-none-eabi from this website. Then I scp to Rpi and unzip it.
But I cannot execute it. The shell told me that cannot execute binary file: Exec format error. Did I download the worng version?
The architecture of Rpi is "armv7l" and the OS I'm using is Pi OS(buster). I thought it belongs to "AArch64 Linux hosted".
Thank you ~
That is ARM v7 architecture.
IIRC, the raspi hardware is armv8 capable machines, but RPI OS runs in aarch32 mode, which is compatibility mode for armv7.
You can also check cpuinfo to be sure about it.
On an ARMv7 kernel/OS(aarch32), armv8 applications cannot be run, but on armv8(aarch64) kernel/OS armv7 applications can be run in aarch32 mode.
Refer ARM's Learn the architecture: Aarch64 Exception Model for more details.
pi#raspberrypi:~ $ cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 108.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 1
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 108.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
the stm is either armv6-m, arv7-m or one of the armv8-ms. The pi itself is armv8. You either need to run the pi in 32 bit aarch32 mode and use a native compiler or use a cross compiler. aarch64 is armv8-a (arm 64 bit, the armv7-a is the aarch32 compatibility mode).
So you will want to get arm-none-eabi, which you claim but you also claimed aarch64 if it were aarch64 then it would be aarch64-none-eabi or some such name.
Like any other computer you can just get or build for (not hard to build gnu toolchain from sources) arm (32 bit) and get the one that can build for stm32.
gcc version 3.x.x to the present, technically, can build code that will run on an stm32.
If you plan to use a C library then even though you can use the native toolchain on an armv7 based linux on the pi, it is arm-whatever-linux-gnueabi not arm-whatever-eabi and may not work for you.
Just get arm-none-eabi based toolchain, use the proper command line options, and be done with it.

Tesseract is Not Working At Another PC

I tried to use tesseract on my project at C# and i finished it works great at my computer but when i try to use this project at another PC first it gave vcruntime140.dll error, i solved it and after it works great except OCR, and i use exactly same version of tesseract at 2 PC. I will call my computer source.
Source PC
Windows10
Project written at VS2017 C#
.NET Framework 3.5
Tesseract Version
tesseract 4.0.0-alpha.20180109
leptonica-1.74.4
libgif 4.1.6(?) : libjpeg 8d (libjpeg-turbo 1.5.0) : libpng 1.6.24 : libtiff 4.0.6 : zlib 1.2.8 : libwebp 0.4.3 : libopenjp2 2.1.0
Target PC
Windows7
It has all dependicies
Tesseract Version
tesseract 4.0.0-alpha.20180109
leptonica-1.74.4
libgif 4.1.6(?) : libjpeg 8d (libjpeg-turbo 1.5.0) : libpng 1.6.24 : libtiff 4.0.6 : zlib 1.2.8 : libwebp 0.4.3 : libopenjp2 2.1.0
I know it has all image format's library but i tried png and tiff both with my last hope =)
Thanks!
Abdullah
It throws this when OCR try to work ;
"the exception was created by an invocation target"

How to install actual JDK on Synology

How can i install a actual jdk on my Synology DS213 air,
I have installed IPKG,JAMVM and JIKE that i can start a RMI-Server on my NAS but when i start the java I get this error:
DiskStation> jikes -cp /opt/lib/rt.jar RunRmiRegistry.java
Found 1 semantic error compiling "RunRmiRegistry.java":
42. for (String string : list) {
^
Semantic Error: Enhanced for loops (also known as foreach loops) are only supported for `-source 1.5' or greater.
On my PC i have installes jdk 8.45.
The Synology DS213 Air can not be get a newer Java then Java 5 so its not impossible to install the actual Java

gpuDevice() toolkit version always 5.5

No matter how I reinstall the CUDA driver and toolkit, when typing gpuDevice(), it always show s:
CUDADevice with properties:
Name: 'Quadro K2000M'
Index: 1
ComputeCapability: '3.0'
SupportsDouble: 1
DriverVersion: 6.5000
ToolkitVersion: 5.5000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 2.1475e+09
FreeMemory: 2.0431e+09
MultiprocessorCount: 2
ClockRateKHz: 745000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 0
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
which I don't understand. Why the toolkit version is always 5.5? Can I upgrade it to 6.5?
As #Robert mentioned, you have to use the same cuda version but not necessarily if you use simple trick (I'm using CUDA 6.0 and MATLAB CUDA version is 5.0). To make it work, you do not need the complicated procedure, nor the mex for compiling all .cu files and copying the xml file ( as in Link) to the directory to compile. Type simply the following two lines in the matlab command,
!nvcc -O3 -DNDEBUG -c mexGPUExample.cu -Xcompiler -fPIC -I/MATLAB_ROOT/extern/include -I/MATLAB_ROOT/toolbox/distcomp/gpu/extern/include;
mex mexGPUExample.o -L/usr/local/cuda-6.0/lib64 -L/MATLAB_ROOT/bin/glnxa64 -lcudart -lcufft -lmwgpu
Then it will magically work even if your ToolkitVersion mismatches. (Change /MATLAB_ROOT to your matlab root path)
Why MATLAB CUDA Toolkit version is different from System CUDA version?
Regarding your question, the installed CUDA version is not the same CUDA that MATLAB use.
If you go to
/matlabroot/bin/maci64 (OS X)
/matlabroot/bin/glnxa64 (unix variant)
depending on your os,
you can see the [dynamic linking library, shared library]
libcudart.5.5.[dylib, so]
libcublas.5.5.[dylib, so]
libcufft.5.5.[dylib, so]
These are the libraries that MATLAB uses. To make matlab to use system libraries, follow the instructions below. (MAC only)
In sum,
The installed cuda version is different from MATLAB cuda since they have their own library
To trick it to load the new library, you might need to use install_name_tool to change the library link
Anyway you don't need it to have same version.
EDIT : How to make MATLAB to use System CUDA Library (OS X)
Make MATLAB to use System CUDA library, The default MATLAB CUDA library version is 5.5 and if you want to use the up-to-date library, read the following
Go to /Applications/MATLAB_R2014a.app/bin/maci64(MAC) or MATLAB_ROOT/bin/glxna64(LINUX)
See the library dependencies of libmwgpu.[dylib, so] this is the entry library that is loaded when you use CUDA
The result would look like
dnab404675:maci64 user$ otool -L libmwgpu.dylib
libmwgpu.dylib:
#rpath/libmwgpu.dylib (compatibility version 0.0.0, current version 0.0.0)
.... Some Libraries
#rpath/libcublas.5.5.dylib (compatibility version 5.5.0, current version 5.5.20)
#rpath/libcudart.5.5.dylib (compatibility version 5.5.0, current version 5.5.20)
#rpath/libcufft.5.5.dylib (compatibility version 5.5.0, current version 5.5.20)
... and more
Our goal is to modify the library dependency of `cublas`, `cudart`, `cufft` to
> /usr/local/cuda/lib/libcublas.dylib (compatibility version 5.5.0, current version 5.5.20)
/usr/local/cuda/lib/libcudart.dylib (compatibility version 5.5.0, current version 5.5.20)
/usr/local/cuda/lib/libcufft.dylib (compatibility version 5.5.0, current version 5.5.20)
Note that if you type gpuDevice, it will still show it as toolkit version 5. But it loads the new version. So how we do that?
Simply type
sudo install_name_tool -change #rpath/libcufft.5.5.dylib /usr/local/cuda/lib/libcufft.dylib libmwgpu.dylib
sudo install_name_tool -change #rpath/libcudart.5.5.dylib /usr/local/cuda/lib/libcudart.dylib libmwgpu.dylib
sudo install_name_tool -change #rpath/libcublas.5.5.dylib /usr/local/cuda/lib/libcublas.dylib libmwgpu.dylib
I still don't know how to change the shared library path in Linux. Probably have to use hexadecimal editor such as HT From Stackoverflow Answer
You can also use CUDA 6.5 with matlab under Windows. The tricky part is, you need to compile the mex files under Visual Studio rather than inside matlab. There are numerous tutorials introducing how to compile mex under VS so there is no need to repeat here. You need only to create a NVIDIA cuda project with .cu as the source, and follow the standard procedures to compile mex.

Trouble installing py2cairo on Mac OSX Lion

I have spent the last several nights trying to install py2cairo on Mac OSX Lion using gcc-4.2 and Python2.6, attempting a number of the approaches mentioned in these links (among many others; as a new user, I can post only two links):
http://www.niconomicon.net/blog/2011/10/09/2120.wrestling.python.snow.leopard
How to install PyCairo 1.10 on Mac OSX with default python
Unfortunately, I'm still running into a problem with the wrong header files being found. See below for my environment settings and the error output from waf build. I'd greatly appreciate any pointers. Thanks!
Steves-Mac-Pro:py2cairo-1.10.0 dr_steve_kramer$ env
MANPATH=/sw/share/man:/usr/share/man:/usr/local/share/man:/usr/X11/man:/usr/local/mysql/man:/sw/lib/perl5/5.12.3/man:/usr/X11R6/man
TERM_PROGRAM=Apple_Terminal
TERM=xterm-256color
SHELL=/bin/bash
TMPDIR=/var/folders/8r/2kt_yqyx2dg2g83m0dyhcy740000gn/T/
LIBRARY_PATH=/Developer/SDKs/MacOSX10.6.sdk/usr/lib
PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
Apple_PubSub_Socket_Render=/tmp/launch-bnnjZo/Render
TERM_PROGRAM_VERSION=303
OLDPWD=/private/tmp
TERM_SESSION_ID=3A9C4E28-D669-4134-A333-A13920514ED7
USER=dr_steve_kramer
LD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/6.3/lib:/Library/Frameworks/Python.framework/Versions/6.3:
COMMAND_MODE=unix2003
SSH_AUTH_SOCK=/tmp/launch-c3CJUO/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0:0
Apple_Ubiquity_Message=/tmp/launch-pYg8fw/Apple_Ubiquity_Message
PATH=/Library/Frameworks/Python.framework/Versions/6.3/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/bin/f2j-0.7/bin:/usr/local/jaxws-ri:/usr/X11R6/bin
MKL_NUM_THREADS=1
C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.6.sdk/usr/include
PWD=/private/tmp/py2cairo-1.10.0
LANG=en_US.UTF-8
JAXWS_HOME=/usr/local/jaxws-ri
CXX=g++-4.2
SHLVL=1
HOME=/Users/dr_steve_kramer
CFLAGS=-I/usr/include/gcc/darwin/4.2/
LINKFLAGS=-search_dylibs_first -L /Library/Frameworks/Python.framework/Versions/6.3/lib/
PYTHONPATH=/Library/Frameworks/Python.framework/Versions/6.3/bin
LOGNAME=dr_steve_kramer
ACLOCAL_FLAGS=-I/usr/local/Cellar/pkg-config/0.25/share/aclocal
PKG_CONFIG_PATH=/sw/bin/pkg-config
ARCHFLAGS=-arch x86_64
INFOPATH=/sw/share/info:/sw/info:/usr/share/info
CC=/usr/bin/gcc-4.2
DISPLAY=/tmp/launch-CzK5Wg/org.x:0
_=/usr/bin/env
Steves-Mac-Pro:py2cairo-1.10.0 dr_steve_kramer$ python2.6 waf configure
./options()
Setting top to : /private/tmp/py2cairo-1.10.0
Setting out to : /private/tmp/py2cairo-1.10.0/build_directory
./configure()
Checking for 'gcc' (c compiler) : ok
Checking for program python : /Library/Frameworks/Python.framework/Versions/6.3/bin/python
python executable '/Library/Frameworks/Python.framework/Versions/6.3/bin/python' different from sys.executable '/Library/Frameworks/Python.framework/Versions/6.3/Resources/Python.app/Contents/MacOS/Python'
Checking for python version : (2, 6, 6, 'final', 0)
Checking for library python2.6 : yes
Checking for program python2.6-config : /Library/Frameworks/Python.framework/Versions/6.3/bin/python2.6-config
Checking for header Python.h : yes
Checking for program pkg-config : /sw/bin/pkg-config
Checking for 'cairo' >= 1.10.0 : yes
Configuration:
PREFIX : /usr/local
LIBDIR : /usr/local/lib
'configure' finished successfully (1.577s)
Steves-Mac-Pro:py2cairo-1.10.0 dr_steve_kramer$ python2.6 waf build
./options()
Waf: Entering directory `/private/tmp/py2cairo-1.10.0/build_directory'
./build()
src/build()
[1/9] c: src/cairomodule.c -> build_directory/src/cairomodule.c.1.o
[2/9] c: src/context.c -> build_directory/src/context.c.1.o
[3/9] c: src/font.c -> build_directory/src/font.c.1.o
[4/9] c: src/path.c -> build_directory/src/path.c.1.o
[5/9] c: src/pattern.c -> build_directory/src/pattern.c.1.o
[6/9] c: src/matrix.c -> build_directory/src/matrix.c.1.o
[7/9] c: src/surface.c -> build_directory/src/surface.c.1.o
[8/9] subst: pycairo.pc.in -> pycairo.pc
In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
from ../src/pattern.c:32,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
from ../src/surface.c:32,
from ../src/matrix.c:32In file included from /Library/Frameworks/Pyth:
:
/usr/include/gcc/darwin/4.2/stdarg.h:5:2:,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85on.framework/Versions/6.3/include/python2.6/unicodeobject.h:4In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85/usr/include/gcc/darwin/4.2/stdarg.h:5:2: ,
from ../src/cairomodule.c:32:
error: :
,
from ../src/path.c:32 /usr/include/gcc/darwin/4.2/stdarg.h:5:2:,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85#error ,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85"This header only supports __MWERKS__." :
,
from ../src/context.c:32error: /usr/include/gcc/darwin/4.2/stdarg.h:5:2:,
from ../src/font.c:32error:
#error /usr/include/gcc/darwin/4.2/stdarg.h:5:2::
:
"This header only supports __MWERKS__." #error /usr/include/gcc/darwin/4.2/stdarg.h:5:2:/usr/include/gcc/darwin/4.2/stdarg.h:5:2:
"This header only supports __MWERKS__."error: #error
error: "This header only supports __MWERKS__."#error error: error:
"This header only supports __MWERKS__."#error #error
"This header only supports __MWERKS__.""This header only supports __MWERKS__."
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/wchar.h:111,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:120,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85,
from ../src/matrix.c:32:
/usr/include/gcc/darwin/4.2/stdarg.h:5:2: error: #error "This header only supports __MWERKS__."
If you haven’t solved this yet, try cairocffi: http://packages.python.org/cairocffi/
In case anyone is still have issues with py2cairo on OSX. I was able to get running by using install_name_tool. The config/build process was working and finding the correct version of python. However the compiled binary was linked against the incorrect version of python. This appears to be a bug in waf build system.
To fix the problem...
$ cd /usr/local/lib/python2.7/site-packages/cairo
$ otool -L _cairo.so
_cairo.so:
/Users/charlie/Downloads/py2cairo/build_directory/src/_cairo.so (compatibility version 0.0.0, current version 0.0.0)
/usr/local/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.2.0)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.6)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
$ sudo install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /Library/Frameworks/Python.framework/Versions/2.7/Python _cairo.so
$ otool -L _cairo.so
_cairo.so:
/Users/charlie/Downloads/py2cairo/build_directory/src/_cairo.so (compatibility version 0.0.0, current version 0.0.0)
/usr/local/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.2.0)
/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.6)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
You can then import and use cairo in the version of python that you ran the waf script with.