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
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