Sanjayraju30 commited on
Commit
cecd6a8
·
verified ·
1 Parent(s): 7112c61

Update src/ocr_engine.py

Browse files
Files changed (1) hide show
  1. 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
- # ✅ Install system lib first (before cv2 is imported)
8
  os.system("apt-get update && apt-get install -y libgl1-mesa-glx")
 
9
 
10
- import cv2 # ✅ delay import until libGL is ready
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)