diff --git a/contrib/tesseract-c_api-demo.py b/contrib/tesseract-c_api-demo.py index 8fed83e2..5eb6f4de 100644 --- a/contrib/tesseract-c_api-demo.py +++ b/contrib/tesseract-c_api-demo.py @@ -29,6 +29,9 @@ lang = "eng" filename = "../phototest.tif" libpath = "/usr/local/lib64/" libpath_w = "../vs2008/DLL_Release/" +TESSDATA_PREFIX = os.environ.get('TESSDATA_PREFIX') +if not TESSDATA_PREFIX: + TESSDATA_PREFIX = "../" if sys.platform == "win32": libname = libpath_w + "libtesseract302.dll" @@ -50,7 +53,7 @@ except: exit(1) tesseract.TessVersion.restype = ctypes.c_char_p -tesseract_version = tesseract.TessVersion() +tesseract_version = tesseract.TessVersion()[:4] # We need to check library version because libtesseract.so.3 is symlink # and can point to other version than 3.02 @@ -60,7 +63,7 @@ if float(tesseract_version) < 3.02: exit(2) api = tesseract.TessBaseAPICreate() -rc = tesseract.TessBaseAPIInit3(api, "", lang); +rc = tesseract.TessBaseAPIInit3(api, TESSDATA_PREFIX, lang); if (rc): tesseract.TessBaseAPIDelete(api) print("Could not initialize tesseract.\n")