SuriRaja commited on
Commit
9f587bb
·
1 Parent(s): 0c61a6b

Update services/overlay_service.py

Browse files
Files changed (1) hide show
  1. services/overlay_service.py +10 -8
services/overlay_service.py CHANGED
@@ -2,15 +2,17 @@ import cv2
2
 
3
  def overlay_boxes(frame, boxes):
4
  for box in boxes:
5
- x1, y1, x2, y2 = map(int, box['box'])
6
- label = box.get('label', 'Anomaly')
7
- confidence = box.get('score', 0)
 
 
 
 
 
8
 
9
- # Draw box
10
  cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
 
 
11
 
12
- # Draw label
13
- text = f"{label} ({confidence:.2f})"
14
- cv2.putText(frame, text, (x1, max(y1 - 10, 0)), cv2.FONT_HERSHEY_SIMPLEX,
15
- 0.5, (255, 0, 0), 2)
16
  return frame
 
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