I don’t know a way to have py tesseract, only have numbers as output

  python, python-tesseract

I don’t know how to have tesseract output with only numbers.

I need this so that it doesn’t think that handwritten numbers are not words.

My code:

try:
    from PIL import Image
except ImportError:
    import Image
import pytesseract
def main():
    pytesseract.pytesseract.tesseract_cmd = r'C:UsersMeAppDataLocalProgramsTesseract-OCRtesseract.exe'
    mylist = pytesseract.image_to_string(Image.open('test.jpg'))
    print(mylist) 
    list2 = mylist.split()
    i = 0
    a = 0
    while i < 2:
        print(list2)
        print("length is {}".format(list2[a]))
        a =a+1
        print("width is {}".format(list2[a]))
        a =a+1
        print("hight is {}".format(list2[a]))
        a =a+1
        i += 1
main()

My image can be checked here

I get an output of:

NQAaus
6

['NQAaus', '6']
length is NQAaus
width is 6

Source: Python Questions

LEAVE A COMMENT