Spaces:
Sleeping
Sleeping
| 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 |