Spaces:
Sleeping
Sleeping
Rename ocr_engine.py to src/ocr_engine.py
Browse files- ocr_engine.py +0 -9
- src/ocr_engine.py +10 -0
ocr_engine.py
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
import pytesseract
|
2 |
-
import re
|
3 |
-
|
4 |
-
def extract_weight_from_image(image):
|
5 |
-
text = pytesseract.image_to_string(image)
|
6 |
-
match = re.search(r"\d+.\d{2}", text)
|
7 |
-
if match:
|
8 |
-
return match.group()
|
9 |
-
return "No weight found"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/ocr_engine.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pytesseract
|
2 |
+
from PIL import Image
|
3 |
+
import re
|
4 |
+
|
5 |
+
def extract_weight_from_image(image):
|
6 |
+
text = pytesseract.image_to_string(image)
|
7 |
+
match = re.search(r"\d+\.\d{2}", text)
|
8 |
+
if match:
|
9 |
+
return match.group()
|
10 |
+
return "No weight found"
|