Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -216,13 +216,8 @@ def blur_im(img,bounds):
|
|
216 |
im[y:y+h, x:x+w] = cv2.GaussianBlur(im[y:y+h, x:x+w],(51,51),0)
|
217 |
|
218 |
|
219 |
-
#fontpath = "tamil/Latha.ttf"
|
220 |
-
#text = "γγ€ζ©γ¦η¦"
|
221 |
text = "New Text"
|
222 |
-
|
223 |
-
|
224 |
-
#font = ImageFont.load("arial.pil")
|
225 |
-
#font = ImageFont.truetype(fontpath, 32)
|
226 |
im = Image.fromarray(im)
|
227 |
for bound in bounds:
|
228 |
p0, p1, p2, p3 = bound[0]
|
@@ -231,14 +226,14 @@ def blur_im(img,bounds):
|
|
231 |
w = int(p2[0]) - int(x)
|
232 |
h = int(p2[1]) - int(y)
|
233 |
draw = ImageDraw.Draw(im)
|
234 |
-
|
235 |
-
font_size=round(int(w)*0.3)
|
236 |
font = ImageFont.truetype("./fonts/unifont-15.0.01.ttf", int(font_size))
|
|
|
|
|
237 |
|
|
|
|
|
238 |
|
239 |
-
|
240 |
-
draw.text((x, y),text, font = font, fill=(0,0,0))
|
241 |
-
#img_tamil = np.array(img_pil)
|
242 |
return im
|
243 |
|
244 |
def draw_boxes(image, bounds, color='blue', width=1):
|
|
|
216 |
im[y:y+h, x:x+w] = cv2.GaussianBlur(im[y:y+h, x:x+w],(51,51),0)
|
217 |
|
218 |
|
|
|
|
|
219 |
text = "New Text"
|
220 |
+
|
|
|
|
|
|
|
221 |
im = Image.fromarray(im)
|
222 |
for bound in bounds:
|
223 |
p0, p1, p2, p3 = bound[0]
|
|
|
226 |
w = int(p2[0]) - int(x)
|
227 |
h = int(p2[1]) - int(y)
|
228 |
draw = ImageDraw.Draw(im)
|
229 |
+
font_size=round(int(w)*0.)
|
|
|
230 |
font = ImageFont.truetype("./fonts/unifont-15.0.01.ttf", int(font_size))
|
231 |
+
draw.text((x, y),text, font = font, fill=(0,0,0))
|
232 |
+
kernel = np.ones((1, 1), np.uint8)
|
233 |
|
234 |
+
im[y:y+h, x:x+w] = cv2.dilate(im[y:y+h, x:x+w], kernel, iterations=1)
|
235 |
+
im[y:y+h, x:x+w] = cv2.erode(im[y:y+h, x:x+w], kernel, iterations=1)
|
236 |
|
|
|
|
|
|
|
237 |
return im
|
238 |
|
239 |
def draw_boxes(image, bounds, color='blue', width=1):
|