Spaces:
Sleeping
Sleeping
File size: 565 Bytes
44db6b3 b82925c 44db6b3 5c4607f 44db6b3 5c4607f 44db6b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import cv2
import pytesseract
import os
from PIL import Image
def preprocess_image_for_ocr(image_path):
image = cv2.imread(image_path)
if image is None:
raise ValueError("Image not found or unable to load.")
return image
def extract_text_from_object(image_path):
preprocessed_image = preprocess_image_for_ocr(image_path)
text = pytesseract.image_to_string(preprocessed_image)
return text
def extract_image_as_whole(image_path):
image = cv2.imread(image_path)
txt= pytesseract.image_to_string(image)
return txt |