5

I want to recognize a image like this:

enter image description here

I am using the following config:

config="--psm 6 --oem 3 -c tessedit_char_whitelist=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ,." 

but when I try to convert that, I get the following:

1581

1

W

I think that the image shows really clearly what is written and think that there is a problem with pytesseract. Can you help?

3
  • it also happened for me, one time it showed me a star as a dot, while there are so many stars in the same image, don't know whats wrong... but i didn't use any configs Commented Sep 20, 2021 at 14:47
  • @GhostOps Yes but with such a clean image this must be possible right? Commented Sep 20, 2021 at 14:48
  • 1
    yeah, dont know whats wrong.. Commented Sep 20, 2021 at 14:49

1 Answer 1

1

Preprocessing the image to obtain a binary image before performing OCR seems to work. You could also try to resize the image so that more details would be seen

enter image description here

Results

158.1 1 IT 
import cv2 import pytesseract pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe" # Grayscale and Otsu's threshold image = cv2.imread('1.png') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1] # Perform text extraction data = pytesseract.image_to_string(thresh, lang='eng', config='--psm 6') print(data) cv2.imshow('thresh', thresh) cv2.waitKey() 
Sign up to request clarification or add additional context in comments.

1 Comment

I resized it and now it works flawless

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.