Spaces:
Build error
Build error
truong-xuan-linh
commited on
Commit
•
d8fc179
1
Parent(s):
f3a3645
Update OCR.py
Browse files- src/OCR.py +3 -3
src/OCR.py
CHANGED
@@ -84,12 +84,12 @@ class OCRDetector:
|
|
84 |
|
85 |
h = y3 - y1
|
86 |
scl = max(h//1000,1)
|
87 |
-
font = ImageFont.truetype("./storage/Roboto-Black.ttf",
|
88 |
img = cv2.rectangle(img, (int(x1), int(y1)), (int(x3), int(y3)), (0, 255, 0), 1)
|
89 |
|
90 |
img_pil = Image.fromarray(img)
|
91 |
draw = ImageDraw.Draw(img_pil)
|
92 |
-
draw.text((int(x1), int(y1-h
|
93 |
img = np.array(img_pil)
|
94 |
# img = cv2.putText(img, text["text"], (int(x1), int(y1)-3), cv2.FONT_HERSHEY_SIMPLEX, 0.3, (255,0,0), 1)
|
95 |
-
return img
|
|
|
84 |
|
85 |
h = y3 - y1
|
86 |
scl = max(h//1000,1)
|
87 |
+
font = ImageFont.truetype("./storage/Roboto-Black.ttf", 22*scl)
|
88 |
img = cv2.rectangle(img, (int(x1), int(y1)), (int(x3), int(y3)), (0, 255, 0), 1)
|
89 |
|
90 |
img_pil = Image.fromarray(img)
|
91 |
draw = ImageDraw.Draw(img_pil)
|
92 |
+
draw.text((int(x1), int(y1-h//2)), text["text"], font = font, fill = (255, 51, 51))
|
93 |
img = np.array(img_pil)
|
94 |
# img = cv2.putText(img, text["text"], (int(x1), int(y1)-3), cv2.FONT_HERSHEY_SIMPLEX, 0.3, (255,0,0), 1)
|
95 |
+
return img
|