In this project, we will learn how to recognize and extract text from the given image using Python. We use OpenCV to load the image and pytesseract module to extract text.
Go to the command prompt and use ''pip install opencv-python'' command to install OpenCV.
Follow this link to install python and OpenCV.
Go to this link and download tesseract module suitable to your system.
After downloading pytesseract setup file, run it
Follow this video to install pytesseract, you have to add the path of pytesseract file to your system environment.
#importing required libraries (opencv and pytesseract) import cv2 import pytesseract
#reading image img = cv2.imread('img.jpg')
#extracting text in the image text = pytesseract.image_to_string(img, lang='eng')
#creating a file with name recognized file = open("recognized_text.txt", "w+") file.close()
#Appending the extracted text into the file file = open("recognized_text.txt","a") file.write(text) file.close()
Submitted by Chereddy Vivek Reddy (Vivek)
Download packets of source code on Coders Packet