lokesh341 commited on
Commit
fb723a9
·
1 Parent(s): 21230b8

Update services/overlay_service.py

Browse files
Files changed (1) hide show
  1. services/overlay_service.py +5 -17
services/overlay_service.py CHANGED
@@ -11,16 +11,6 @@ logging.basicConfig(
11
  )
12
 
13
  def overlay_boxes(frame: np.ndarray, detected_items: List[Dict[str, Any]]) -> np.ndarray:
14
- """
15
- Overlay bounding boxes and labels on the frame for detected items.
16
-
17
- Args:
18
- frame (np.ndarray): Input frame in BGR format.
19
- detected_items (List[Dict[str, Any]]): List of detected items with coordinates and labels.
20
-
21
- Returns:
22
- np.ndarray: Frame with overlaid bounding boxes and labels.
23
- """
24
  # Validate inputs
25
  if not isinstance(frame, np.ndarray) or frame.size == 0:
26
  logging.error("Invalid input frame provided to overlay_service.")
@@ -31,21 +21,19 @@ def overlay_boxes(frame: np.ndarray, detected_items: List[Dict[str, Any]]) -> np
31
 
32
  try:
33
  for item in detected_items:
34
- # Check for required keys
35
  if "coordinates" not in item or "label" not in item:
36
  logging.warning(f"Skipping item without coordinates or label: {item}")
37
  continue
38
 
39
- # Extract coordinates and label
40
  x_min, y_min, x_max, y_max = item["coordinates"]
41
  label = item["label"]
42
 
43
- # Define colors based on detection type
44
  type_colors = {
45
- "crack": (147, 112, 219), # Light Purple (green + pink mix) for cracks
46
- "pothole": (255, 127, 80), # Coral (red + orange mix) for potholes
47
- "signage": (0, 191, 255), # DeepSkyBlue for signage
48
- "default": (0, 255, 255) # Yellow as fallback
49
  }
50
  color = type_colors.get(item.get("type", "default"), type_colors["default"])
51
 
 
11
  )
12
 
13
  def overlay_boxes(frame: np.ndarray, detected_items: List[Dict[str, Any]]) -> np.ndarray:
 
 
 
 
 
 
 
 
 
 
14
  # Validate inputs
15
  if not isinstance(frame, np.ndarray) or frame.size == 0:
16
  logging.error("Invalid input frame provided to overlay_service.")
 
21
 
22
  try:
23
  for item in detected_items:
 
24
  if "coordinates" not in item or "label" not in item:
25
  logging.warning(f"Skipping item without coordinates or label: {item}")
26
  continue
27
 
 
28
  x_min, y_min, x_max, y_max = item["coordinates"]
29
  label = item["label"]
30
 
31
+ # Define colors for Operations Maintenance
32
  type_colors = {
33
+ "crack": (0, 0, 255), # Blue for cracks
34
+ "pothole": (255, 0, 0), # Red for potholes
35
+ "signage": (0, 0, 255), # Blue for signage
36
+ "default": (0, 255, 255) # Yellow as fallback
37
  }
38
  color = type_colors.get(item.get("type", "default"), type_colors["default"])
39