Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,10 @@ import os
|
|
4 |
|
5 |
def process(image: str, lang: str = 'eng') -> str:
|
6 |
try:
|
7 |
-
|
|
|
|
|
|
|
8 |
os.remove(image)
|
9 |
return result
|
10 |
except Exception as e:
|
|
|
4 |
|
5 |
def process(image: str, lang: str = 'eng') -> str:
|
6 |
try:
|
7 |
+
img = cv2.imread(image)
|
8 |
+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
9 |
+
threshold_img = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
|
10 |
+
result = pytesseract.image_to_string(threshold_img, lang=lang)
|
11 |
os.remove(image)
|
12 |
return result
|
13 |
except Exception as e:
|