Search code examples
pythonopencvtesseractpython-tesseract

Pytesseract: Cannot read digits on a relatively good quality image


I have an image as below:

enter image description here

With tesseract command:

pytesseract.image_to_string(box_img_6, config="--lang= 'eng' --psm 6 --oem 3")

I am getting the output: 'nu '

I think tesseract should perform better on this image and at least read some of the digits.

Can you help me to improve the performance of Tesseract?

Thank you .


Solution

  • Try this code

    import pytesseract
    from PIL import Image
    pytesseract.pytesseract.tesseract_cmd = (r"C:\Tesseract-OCR\tesseract.exe")
    text = pytesseract.image_to_string(Image.open(r"a.jpg"), lang='eng',
                            config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789')
    
    print(text)
    

    Output

    **3008**