Spaces:
Sleeping
Sleeping
import cv2 | |
import pytesseract | |
from PIL import Image | |
def extract_weight(img_path): | |
img = cv2.imread(img_path) | |
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | |
text = pytesseract.image_to_string(gray, config='--psm 7 digits') | |
return ''.join(filter(lambda x: x in '0123456789.', text)) | |