justin2341 commited on
Commit
49056d9
·
verified ·
1 Parent(s): 715b2be

Update demo.py

Browse files
Files changed (1) hide show
  1. demo.py +2 -1
demo.py CHANGED
@@ -19,9 +19,10 @@ def plot_one_box(x, img, color=None, label=None, score=None, line_thickness=3):
19
  cv2.rectangle(img, c1, c2, color, -1, cv2.LINE_AA) # filled
20
  cv2.putText(img, label, (c1[0], c1[1] - 2), 0, tl / 3, [0, 0, 0], thickness=tf, lineType=cv2.LINE_AA)
21
 
 
 
22
  c1 = c2
23
  c2 = c1[0] + t_size[0], c1[1] + t_size[1] + 3
24
- pro = f"{score:.2f}"
25
  cv2.rectangle(img, c1, c2, [0, 255, 255], -1, cv2.LINE_AA) # filled
26
  cv2.putText(img, pro, (c1[0], c2[1] - 2), 0, tl / 3, [0, 0, 0], thickness=tf, lineType=cv2.LINE_AA)
27
  return img
 
19
  cv2.rectangle(img, c1, c2, color, -1, cv2.LINE_AA) # filled
20
  cv2.putText(img, label, (c1[0], c1[1] - 2), 0, tl / 3, [0, 0, 0], thickness=tf, lineType=cv2.LINE_AA)
21
 
22
+ pro = f"{score:.3f}"
23
+ t_size = cv2.getTextSize(pro, 0, fontScale=tl / 3, thickness=tf)[0]
24
  c1 = c2
25
  c2 = c1[0] + t_size[0], c1[1] + t_size[1] + 3
 
26
  cv2.rectangle(img, c1, c2, [0, 255, 255], -1, cv2.LINE_AA) # filled
27
  cv2.putText(img, pro, (c1[0], c2[1] - 2), 0, tl / 3, [0, 0, 0], thickness=tf, lineType=cv2.LINE_AA)
28
  return img