How to convert image to text using OCR?

Yes, it is possible.

We can extract text from images with the help of Tesseract OCR library.

Let’s start how can we do this?

Below code extract text from the above images:

import pytesseract

# adds image processing capabilities 
from PIL import Image

img = Image.open('img.png')
pytesseract.pytesseract.tesseract_cmd ='Tesseract-OCR/tesseract.exe'

result = pytesseract.image_to_string(img)
print(result)

Output:

“Word count writing mistakes plagiarism Check Now”

Firstly we need to add Tesseract-OCR library in our system.

Create a new Python file main.py and import pytesseract and pillow library.

Read image and use pytesseract image_to_string function to extract text from image.

Leave a Comment

Your email address will not be published. Required fields are marked *