1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] I'm having problems recognizing text from a picture, python

Discussão em 'Python' iniciado por Stack, Setembro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I was given a school project for recognizing various kinds of CAPTCHA, and I had some difficulties with its implementation.

    Images of this type will be fed into input [​IMG],[​IMG],[​IMG].

    I handle them with the following code:

    import cv2
    import pytesseract

    # load image
    fname = 'picture.png'
    im = cv2.imread(fname,cv2.COLOR_RGB2GRAY)

    pytesseract.pytesseract.tesseract_cmd = r'C:\Tesseract-OCR\tesseract.exe'

    im = im[0:90, 35:150]

    im = cv2.blur(im,(3,3))

    im = cv2.threshold(im, 223 , 250, cv2.THRESH_BINARY)
    im = im[1]

    cv2.imshow('',im)
    cv2.waitKey(0)


    After all processing, the image looks like this:[​IMG] And at this point, I have a problem, how can I modify the image to good readability by the computer, so that instead of the wrong TAREQ. he would display the 7TXB6Q

    I am trying to display text from an image with the pytesseract library as follows

    data = pytesseract.image_to_string(im, lang='eng', config='--psm 6 --oem 3 -c tessedit_char_whitelist= ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
    print(data)


    I am writing here hoping to get valuable advice (perhaps you know the most suitable way to get text from a picture or process the image pinned above). )


    More images

    [​IMG] [​IMG] [​IMG] [​IMG]

    Continue reading...

Compartilhe esta Página