SuriRaja commited on
Commit
0b21e00
·
1 Parent(s): 80bd48b

Update services/overlay_service.py

Browse files
Files changed (1) hide show
  1. services/overlay_service.py +6 -17
services/overlay_service.py CHANGED
@@ -1,21 +1,10 @@
1
  import cv2
2
 
3
- def overlay_boxes(image_path, boxes):
4
- image = cv2.imread(image_path)
5
- if image is None:
6
- return None
7
-
8
  for box in boxes:
9
- x1, y1, x2, y2, label = box
10
- color = (0, 255, 0) if label == "normal" else (0, 0, 255)
11
- cv2.rectangle(image, (x1, y1), (x2, y2), color, 2)
12
- cv2.putText(
13
- image,
14
- label,
15
- (x1, y1 - 10),
16
- cv2.FONT_HERSHEY_SIMPLEX,
17
- 0.5,
18
- color,
19
- 2
20
- )
21
  return image
 
1
  import cv2
2
 
3
+ def overlay_boxes(image, boxes):
4
+ # Directly use the image (NumPy array)
 
 
 
5
  for box in boxes:
6
+ x, y, w, h = box
7
+ x1, y1, x2, y2 = int(x), int(y), int(x + w), int(y + h)
8
+ cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
9
+ cv2.putText(image, 'Anomaly', (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2)
 
 
 
 
 
 
 
 
10
  return image