X-Git-Url: https://us-delaporte.pagekite.me/gitweb/dotfiles.git/blobdiff_plain/e8ff18b7965dad345f987be4bba7585288519395..d08a9f3b8d9754ddb33a3306558239a9dfa0abd9:/files/ocr/ocr.py diff --git a/files/ocr/ocr.py b/files/ocr/ocr.py index 795a83b..61a69ba 100644 --- a/files/ocr/ocr.py +++ b/files/ocr/ocr.py @@ -27,9 +27,12 @@ def ocr_directory(input_dir): input_path = os.path.join(root, file_name) output_path = os.path.join(root, file_name.replace('.', '_ocr.')) - # Perform OCR on the image - text = ocr_image(ocr, input_path) - + text = None + if os.path.exists(output_path): + print(f'{output_path} exists.') + else: + # Perform OCR on the image + text = ocr_image(ocr, input_path) if text: # Write the OCR result to a JSON file json_output_path = output_path.rsplit('.', 1)[0] + '.json'