Update ocr_engine.py
Browse files- ocr_engine.py +4 -4
ocr_engine.py
CHANGED
@@ -3,7 +3,7 @@ import pytesseract
|
|
3 |
from PIL import Image
|
4 |
|
5 |
def extract_weight(img_path):
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
3 |
from PIL import Image
|
4 |
|
5 |
def extract_weight(img_path):
|
6 |
+
img = cv2.imread(img_path)
|
7 |
+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
8 |
+
text = pytesseract.image_to_string(gray, config='--psm 7 digits')
|
9 |
+
return ''.join(filter(lambda x: x in '0123456789.', text))
|