Skip to content

Latest commit

 

History

History
16 lines (13 loc) · 596 Bytes

README.md

File metadata and controls

16 lines (13 loc) · 596 Bytes

image_to_text

from PIL import Image import pytesseract # Import the pytesseract module

class ImageReader: def init(self, tesseract_path): pytesseract.pytesseract.tesseract_cmd = tesseract_path

def extract_text(self, image_path):
    return pytesseract.image_to_string(Image.open(image_path))

if name == 'main': tesseract_path = r'C:\Program Files\Tesseract-OCR\tesseract.exe' image_path = r'C:\Users\abhij\OneDrive\Desktop\Image_extract\newpoem.png' extracted_text = ImageReader(tesseract_path).extract_text(image_path) print(extracted_text)