1

I using Tesseract OCR to recognizing my below picture (it is an image meter electric) but it not working. I have not permitted to use Machine learning or deep learning. Does anyone have some other technique that I can use to solve my problem? please let give to me a guide. Thank you for reading.

This my root image: enter image description here

This image that I have processed must to recognizing digits
enter image description here

This my code:

import cv2
import pytesseract as pts
pts.pytesseract.tesseract_cmd = r'C:\Users\Thep Ho\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'

img = cv2.imread("images/text1.jpg")
text = pts.image_to_string(img)
print(text)
thep200
  • 29
  • 6
  • Did you already check [this](https://stackoverflow.com/questions/46574142/pytesseract-using-tesseract-4-0-numbers-only-not-working) and [this](https://stackoverflow.com/questions/11304286/make-tesseract-recognise-numbers-only/19787319) ? – Yunus Temurlenk Nov 30 '20 at 05:49

1 Answers1

0
  • If you apply adaptive-thresholding to the input image:

  • enter image description here

  • Now, if you apply regular-expression to remove all non-numeric variables from the extracted text:

    • 99951
      

Code:


import re
import cv2
import pytesseract

img = cv2.imread("Eadxj.png")
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
flt = cv2.adaptiveThreshold(gry,
                            252, cv2.ADAPTIVE_THRESH_MEAN_C,
                            cv2.THRESH_BINARY_INV, 31, 7)
txt = pytesseract.image_to_string(flt)
txt_int = re.sub("[^0-9]", "", txt)
print(txt_int)

But if you are allowed to use deep-learning, result will be:

enter image description here

Ahmet
  • 7,527
  • 3
  • 23
  • 47