Spaces:
Runtime error
Runtime error
Update services/under_construction/culvert_check.py
Browse files
services/under_construction/culvert_check.py
CHANGED
|
@@ -26,17 +26,6 @@ except Exception as e:
|
|
| 26 |
model = None
|
| 27 |
|
| 28 |
def process_culverts(frame: np.ndarray) -> Tuple[List[Dict[str, Any]], np.ndarray]:
|
| 29 |
-
"""
|
| 30 |
-
Detect culverts in a video frame using YOLOv8n.
|
| 31 |
-
|
| 32 |
-
Args:
|
| 33 |
-
frame (np.ndarray): Input frame in BGR format.
|
| 34 |
-
|
| 35 |
-
Returns:
|
| 36 |
-
Tuple[List[Dict[str, Any]], np.ndarray]: A tuple containing:
|
| 37 |
-
- List of detected culverts.
|
| 38 |
-
- Annotated frame with bounding boxes and labels.
|
| 39 |
-
"""
|
| 40 |
# Validate input frame
|
| 41 |
if not isinstance(frame, np.ndarray) or frame.size == 0:
|
| 42 |
logging.error("Invalid input frame provided to culvert_check.")
|
|
@@ -78,7 +67,7 @@ def process_culverts(frame: np.ndarray) -> Tuple[List[Dict[str, Any]], np.ndarra
|
|
| 78 |
"coordinates": [x_min, y_min, x_max, y_max]
|
| 79 |
})
|
| 80 |
|
| 81 |
-
color = (
|
| 82 |
cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), color, 2)
|
| 83 |
cv2.putText(
|
| 84 |
frame,
|
|
|
|
| 26 |
model = None
|
| 27 |
|
| 28 |
def process_culverts(frame: np.ndarray) -> Tuple[List[Dict[str, Any]], np.ndarray]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# Validate input frame
|
| 30 |
if not isinstance(frame, np.ndarray) or frame.size == 0:
|
| 31 |
logging.error("Invalid input frame provided to culvert_check.")
|
|
|
|
| 67 |
"coordinates": [x_min, y_min, x_max, y_max]
|
| 68 |
})
|
| 69 |
|
| 70 |
+
color = (0, 255, 0) # Green for culverts
|
| 71 |
cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), color, 2)
|
| 72 |
cv2.putText(
|
| 73 |
frame,
|