tlm_main.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:TalosLibraryMate 作者: jim-hart 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号