# Sumber: https://github.com/YukaLangbuana/KTP-OCR # sudo apt install tesseract-ocr-ind # ~/env/bin/pip install PyTesseract opencv-python import sys from cv2 import ( imread, threshold, cvtColor, COLOR_BGR2GRAY, THRESH_TRUNC, ) from pytesseract import image_to_string filename = sys.argv[1] img = imread(filename) gray = cvtColor(img, COLOR_BGR2GRAY) th, threshed = threshold(gray, 127, 255, THRESH_TRUNC) s = image_to_string((threshed), lang='ind') for line in s.splitlines(): print([line])