I’m trying to use a RaspberryPi with a camera to snap a picture of an electricity meter and OCR the image.
This is the source image
This is the image after the CV processing
This is the image without the thresholding
import pytesseract
import cv2
img = cv2.imread('meter2.jpg',cv2.IMREAD_GRAYSCALE)
img = cv2.bitwise_not(img)
img = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,11,2)
cv2.imwrite('meter-processed.jpg',img)
custom_config = r'--oem 3 --psm 11 -c tessedit_char_whitelist=0123456789'
num = pytesseract.image_to_string(img,config=custom_config)
print (num)
This doesn’t work. With the thresholding I’m not getting anything, without it I’m getting some digits, usually wrong and incomplete.
It seems like this should be relatively simple and yet I can’t seem to OCR these numbers. Any help will be greatly appreciated.
Thanks!