I am trying to develop a meter reading detection system. This is the picture
I need to get the meter reading 27599 as the output. I used this code:
import pytesseract
import cv2
image = cv2.imread('read2.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
(H, W) = gray.shape
rectKernel = cv2.getStructuringElement(cv2.MORPH_RECT, (20, 7))
gray = cv2.GaussianBlur(gray, (1, 3), 0)
blackhat = cv2.morphologyEx(gray, cv2.MORPH_BLACKHAT, rectKernel)
res = cv2.threshold(blackhat, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
pytesseract.image_to_string(res, config='--psm 12 --oem 3 digits')
I get this output:
'.\n\n-\n\n3\n\n7\n\n7\n\n3\n\n-2105 566.261586\n\n161200\n\n310010\n\n--\n\n.-\n\n.\n\n5\n\x0c'
This is my first OCR project. Any help will be appreciated.
Well, there are a lot of texts there that can be removed before we start reading the actual meter number. On the other hand, we can limit our OCR to just numbers in order to prevent false positives (As a few 7-segment numbers are like alphabetical letters).
Since tesseract is not working well enough on 7-segment numbers. I will use EasyOCR.
So the procedure would be like this:
detected number: 27599