1

I am trying to extract numbers from an image using pytesseract but it does not return any text. Here is my code.

from PIL import Image
import pytesseract
im = Image.open('time.png')

custom_oem_psm_config = r'--oem 3 --psm 11 -c tessedit_char_whitelist="0123456789"'# -c preserve_interword_spaces=0'
text= pytesseract.pytesseract.image_to_string(im, config=custom_oem_psm_config)
print(text) 

Here is my image

time

Here is the output

enter image description here

JAMSHAID
  • 1,258
  • 9
  • 32

1 Answers1

0

Pyteserract is not able to extract from all images.

It is mostly able to extract text which is similar to normal fonts we use on Microsoft word, notepad, etc.

Msvstl
  • 1,116
  • 5
  • 21
  • what should I use for fonts like those shown in the above image?? – JAMSHAID Aug 09 '22 at 12:00
  • @JAMSHAID The sample images that pyteserract can extract can be found in this [link](https://github.com/madmaze/pytesseract/tree/master/tests/data). Unfortunately, the image you are trying is not possible – Msvstl Aug 09 '22 at 12:04
  • is there any other library I can use for it? – JAMSHAID Aug 09 '22 at 12:08
  • @JAMSHAID You can check this https://stackoverflow.com/a/61241216/13779320 – Msvstl Aug 09 '22 at 12:38