lokesh341 commited on
Commit
0494fce
·
1 Parent(s): eb6ee52

Update services/road_safety/pothole_crack_detection.py

Browse files
services/road_safety/pothole_crack_detection.py CHANGED
@@ -43,12 +43,13 @@ def detect_potholes_and_cracks(frame):
43
  label = model.names[cls]
44
  if label not in ["crack", "pothole", "debris"]:
45
  continue
46
- xyxy = box.xyxy[0).cpu().numpy().astype(int)
 
47
  x_min, y_min, x_max, y_max = xyxy
48
 
49
  severity = None
50
  if label == "crack":
51
- severity = (255, 0, 0) # Red
52
  severity = random.choice(["low", "medium", "high"])
53
  elif label == "pothole":
54
  color = (0, 255, 0) # Green
@@ -69,7 +70,7 @@ def detect_potholes_and_cracks(frame):
69
 
70
  cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), color, 2)
71
  cv2.putText(frame, detection_label, (x_min, y_min - 10),
72
- cv2.FONT_HERSHEY_SIMPLEXSIMPLEX, 0.6, color, 2)
73
 
74
  line_counter += 1
75
 
 
43
  label = model.names[cls]
44
  if label not in ["crack", "pothole", "debris"]:
45
  continue
46
+ # Fixed syntax error: Changed box.xyxy[0) to box.xyxy[0]
47
+ xyxy = box.xyxy[0].cpu().numpy().astype(int)
48
  x_min, y_min, x_max, y_max = xyxy
49
 
50
  severity = None
51
  if label == "crack":
52
+ color = (255, 0, 0) # Red
53
  severity = random.choice(["low", "medium", "high"])
54
  elif label == "pothole":
55
  color = (0, 255, 0) # Green
 
70
 
71
  cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), color, 2)
72
  cv2.putText(frame, detection_label, (x_min, y_min - 10),
73
+ cv2.FONT_HERSHEY_SIMPLEX, 0.6, color, 2)
74
 
75
  line_counter += 1
76