I’m trying to read text on this image using pytesseract library.
original-screenshot.png
Here is my code:
path = 'original-screenshot.png'
image = cv2.imread(path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_MEAN_C,
cv2.THRESH_BINARY_INV, 101, -69)
cv2.imwrite('screenshot.png', image)
custom_config = r'--oem 3 --psm 7 -l eng -c tessedit_char_whitelist=abcdefghigklmnopqrstuvwxyz0123456789'
text = pytesseract.image_to_string(image, config=custom_config)
print(text)
Processed Image:
screenshot.png
Text Output:
01991f5
Expected Output:
o1991f5
New contributor
ThunderFound is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.