Skip to content

Instantly share code, notes, and snippets.

@Wujek280
Created July 19, 2022 10:03
Show Gist options
  • Save Wujek280/99a360b72d964e758bea3c32b837e8b3 to your computer and use it in GitHub Desktop.
Save Wujek280/99a360b72d964e758bea3c32b837e8b3 to your computer and use it in GitHub Desktop.
OCR
#! /usr/bin/env python3
# pip install pytesseract
#
# Simple cli ocr using pytesseract library
# License MIT
# Author JS.0N
import os
import sys
import numpy as np
from PIL import Image
import pytesseract
# import cv2
for file in sys.argv:
if(file == './ocr.py' or file.endswith('/ocr')):
continue
filename = file ## sys.argv[i]
img1 = np.array(Image.open(filename))
# text = pytesseract.image_to_string(img1, nice=4, config='outputbase digits')
text = pytesseract.image_to_string(img1, nice=4)
print(text)
print(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment