how to recognize or read text from image in python window

0
4718

Overview

extracting text from image using Tesseract ocr
image can be like
-screenshot
-printed page photo
-scanned image
-camera capture image
-window or any other application error message popup screenshot
etc (NOTE:input image should not blurry or noisy)
for recognize or read text you need to follow these steps
-first you should have knowledge of python if not then you need to first watch our video “Python install and helloworld program Tutorial” url : https://youtu.be/oTEf-fij-9g

-download and install tesseract Ocr Library
https://github.com/UB-Mannheim/tesseract/wiki

and add tesseract installation dir path into Environment variables } PATH } New

or use below line on start of your script
pytesseract.pytesseract.tesseract_cmd = r”C:\Program Files (x86)\Tesseract-OCR\tesseract.exe”

then install 2 python libraries
pip install pytesseract
&
pip install pillow

*************Example Code (example.py)**************
 from PIL import Image

import pytesseract

#uncomment below line if you dont want to set "Environment variables" path
 #pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"

im = Image.open("sample1.jpg")

text = pytesseract.image_to_string(im, lang = 'eng')

print(text)

******************************************

thats all
thank you for watching
keep subscribe our channel h2zone

Summary

To using Tesseract ocr we can extract text from image like screenshot,printed page photo,scanned image,camera capture image,error message screenshot etc