SuriRaja commited on
Commit
798d63b
·
1 Parent(s): b8cdeae

Update services/overlay_service.py

Browse files
Files changed (1) hide show
  1. services/overlay_service.py +5 -13
services/overlay_service.py CHANGED
@@ -2,17 +2,9 @@ import cv2
2
 
3
  def overlay_boxes(frame, boxes):
4
  for box in boxes:
5
- score = box['score']
6
- label = box['label']
7
- bbox = box['box'] # x, y, width, height
8
-
9
- x1 = int(bbox['xmin'])
10
- y1 = int(bbox['ymin'])
11
- x2 = int(bbox['xmax'])
12
- y2 = int(bbox['ymax'])
13
-
14
- cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
15
- cv2.putText(frame, f"{label}: {score:.2f}", (x1, y1 - 10),
16
- cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
17
-
18
  return frame
 
2
 
3
  def overlay_boxes(frame, boxes):
4
  for box in boxes:
5
+ x_min, y_min, x_max, y_max, score, label = box
6
+ color = (0, 255, 0) if score > 0.5 else (0, 0, 255)
7
+ cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), color, 2)
8
+ text = f"{label}: {score:.2f}"
9
+ cv2.putText(frame, text, (x_min, y_min - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 1)
 
 
 
 
 
 
 
 
10
  return frame