Using Tesseract To Read Dates From A Small Images
I have a rather small set of images which contains dates. The size might be a problem, but I'd say that the quality is OK. I have followed the guidelines to provide the clearest im
Solution 1:
You need to know the followings:
Now if we center the image (by adding borders):
Second, we need to make the characters in the image bold to make the OCR result accurate.
Now OCR:
29MAR2021
Code:
import cv2
import pytesseract
# Load the image
img = cv2.imread("xsGBK.jpg")
# Center the image
img = cv2.copyMakeBorder(img, 50, 50, 50, 50, cv2.BORDER_CONSTANT, value=[0, 0, 0])
# Convert to the gray-scale
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Dilate
gry = cv2.dilate(gry, None, iterations=1)
# OCRprint(pytesseract.image_to_string(gry))
# Display
cv2.imshow("", gry)
cv2.waitKey(0)
Post a Comment for "Using Tesseract To Read Dates From A Small Images"