error in running tesseract with API example PYTHON

147 views
Skip to first unread message

nick

unread,
May 21, 2018, 3:31:51 AM5/21/18
to tesseract-ocr
hi

i want to run tesseract API python with bellow codes, but raised error:

import os
import ctypes

lang = "eng"
filename = "/usr/src/tesseract-ocr/phototest.tif"
libname = "/usr/local/lib64/libtesseract.so.3"
TESSDATA_PREFIX = os.environ.get('TESSDATA_PREFIX')
if not TESSDATA_PREFIX:
    TESSDATA_PREFIX = "../"

tesseract = ctypes.cdll.LoadLibrary(libname)
tesseract.TessVersion.restype = ctypes.c_char_p
tesseract_version = tesseract.TessVersion()
api = tesseract.TessBaseAPICreate()
rc = tesseract.TessBaseAPIInit3(api, TESSDATA_PREFIX, lang)
if (rc):
    tesseract.TessBaseAPIDelete(api)
    print("Could not initialize tesseract.\n")
    exit(3)

text_out = tesseract.TessBaseAPIProcessPages(api, filename, None, 0)
result_text = ctypes.string_at(text_out)

print 'Tesseract-ocr version', tesseract_version
print result_text

could anyone help me , how to resolve it ?

thanks 

nick

unread,
May 21, 2018, 3:32:56 AM5/21/18
to tesseract-ocr
error was :

Error in findFileFormatStream: failed to read first 12 bytes of file

terminate called after throwing an instance of 'std::ios_base::failure[abi:cxx11]'

what(): basic_filebuf::underflow error reading the file: iostream error

Reply all
Reply to author
Forward
0 new messages