Created
February 5, 2023 09:10
-
-
Save paulwababu/95b80e2eebf300150cc2faaf201261c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytesseract | |
import cv2 | |
# Read the ID image into memory | |
image = cv2.imread("polo.jpg") | |
# Pre-process the image by converting it to grayscale and applying thresholding | |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | |
thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1] | |
# Run OCR on the pre-processed image | |
text = pytesseract.image_to_string(thresh, lang="eng") | |
print(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment