Auto-weight-logger2 / ocr_engine.py
Sanjayraju30's picture
Update ocr_engine.py
79d34b2 verified
raw
history blame
296 Bytes
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))