Spaces:
Sleeping
Sleeping
Update src/ocr_engine.py
Browse files- src/ocr_engine.py +3 -3
src/ocr_engine.py
CHANGED
@@ -4,11 +4,11 @@ import pytesseract
|
|
4 |
from PIL import Image
|
5 |
|
6 |
def extract_weight_from_image(pil_img):
|
7 |
-
# ✅
|
8 |
os.system("apt-get update && apt-get install -y libgl1-mesa-glx")
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
image = np.array(pil_img.convert("RGB"))
|
13 |
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
14 |
blur = cv2.GaussianBlur(gray, (3, 3), 0)
|
|
|
4 |
from PIL import Image
|
5 |
|
6 |
def extract_weight_from_image(pil_img):
|
7 |
+
# ✅ Fix for missing libGL (required by OpenCV)
|
8 |
os.system("apt-get update && apt-get install -y libgl1-mesa-glx")
|
9 |
+
import cv2 # Must be imported after installing libGL
|
10 |
|
11 |
+
# ✅ OCR pipeline
|
|
|
12 |
image = np.array(pil_img.convert("RGB"))
|
13 |
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
14 |
blur = cv2.GaussianBlur(gray, (3, 3), 0)
|