def process_ocr(force=False):
"""Invokes tesseract-ocr and translate_hex_values(), after which, the
converted text is displayed to the screen
:param force: If True, all images will be scanned regardless if they've been processed previously.
force=True also skips the message/filename process
"""
path = TesseractConfig()
scan_logs = ScanLogs()
skipped_files = 0
tessdata = '--tessdata-dir "{}"'.format(path.tessdata)
for file in os.listdir(path.screenshots):
if force or not scan_logs.check_if_scanned(file):
image = Image.open('{}\\{}'.format(path.screenshots, file))
converted_text = TextConversion(pytesseract.image_to_string(image, config=tessdata))
print(converted_text)
if not force:
scan_logs.logs = {file: str(converted_text)}
else:
skipped_files += 1
print("\n----------Scan Complete-----------")
if skipped_files:
print_delay("{} Files Skipped (Already Scanned)".format(skipped_files))
评论列表
文章目录