python - Building portable Tesseract OCR libraries in Linux -
is there way build , use tesseract library , corresponding leptonica library (because tesseract depends on leptonica) can done in windows?
i compiled these libraries according instructions, seems libtesseract.so.3.0.2
includes fixed path leptonica shared library:
$ ldd libtesseract.so.3.0.2 linux-vdso.so.1 => (0x00007fffbc5ff000) **liblept.so.4 => /usr/local/lib/liblept.so.4 (0x00007fa8400fd000)** libpng12.so.0 => /usr/lib64/libpng12.so.0 (0x00007fa83fcae000) libjpeg.so.62 => /usr/lib64/libjpeg.so.62 (0x00007fa83fa5e000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa83f5e4000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fa83f2de000) libm.so.6 => /lib64/libm.so.6 (0x00007fa83f059000) libc.so.6 => /lib64/libc.so.6 (0x00007fa83ecc5000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fa83eaaf000) /lib64/ld-linux-x86-64.so.2 (0x0000003080200000)
it results in oserror while running application on workstation leptonica not installed:
oserror: liblept.so.4: cannot open shared object file: no such file or directory
typical use case follows (the tesseract , leptonica libraries in same folder):
import ctypes import os import sys lang = 'eng' os.putenv('tessdata_prefix', ".") tessdata = os.environ.get('tessdata_prefix') tess_libpath = "." tess_libname = "libtesseract.so.3.0.2" # tess_libname = "libtesseract302.dll" works in windows, no need add leponica library file os.environ["path"] += os.pathsep + tess_libpath tesseract = none try: tesseract = ctypes.cdll.loadlibrary(os.path.join(tess_libpath, tess_libname)) except oserror, err: raise class _tessbaseapi(ctypes.structure): pass tessbaseapi = ctypes.pointer(_tessbaseapi) tesseract.tessbaseapicreate.restype = tessbaseapi tesseract.tessbaseapidelete.restype = none tesseract.tessbaseapidelete.argtypes = [tessbaseapi] tesseract.tessbaseapiinit3.argtypes = [tessbaseapi, ctypes.c_char_p, ctypes.c_char_p] tesseract.tessbaseapisetimage.restype = none tesseract.tessbaseapisetimage.argtypes = [tessbaseapi, ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int] tesseract.tessbaseapigetutf8text.restype = ctypes.c_char_p tesseract.tessbaseapigetutf8text.argtypes = [tessbaseapi]
i tried add options --disable-shared --enable-static
when configuring tesseract, didn't work out.
in case target os centos 6.5, appreciate general answer well.
ldd
can't tell whether there absolute path in library. instead, uses standard shared library search path , prints finds.
to check whether loading work different folder well, try this:
> mkdir tmp > cd tmp > cp /usr/local/lib/liblept.so.4 > ld_library_path=$pwd:$ld_library_path ldd libtesseract.so.3.0.2
it should show liblept.so.4
tmp
folder.
Comments
Post a Comment