pythonopencvpython-tesseract

How to get text from image correctly


Belowing is my image. I want to read text from it. And I found a software called tesseract. I installed it and tried. But I failed to work it out.

My Image

Someone can help me, how can I get the correct result?


Solution

  • Again, question is very basic. You can find tonnes of examples on the internet. Just google something like OCR or pytesseract. You need to get a working installation of tesseract on your machine. Follow the steps here.

    The code below can do this without any pre-processing:

    import cv2
    import pytesseract
    pytesseract.pytesseract.tesseract_cmd = "C:/Program Files/Tesseract-OCR/tesseract.exe"
    im = cv2.imread("text.jpg")
    text = pytesseract.image_to_string(im, config='-l eng --psm 7')
    print(text)
    

    The result:

    1.331 dBm
    

    Hope this helps you further. If you post another question, please make sure to stick to a point and include relevant information in your question.