Spaces:
Sleeping
Sleeping
Update services/crack_detection_service.py
Browse files
services/crack_detection_service.py
CHANGED
|
@@ -4,10 +4,10 @@ import numpy as np
|
|
| 4 |
# Define road boundary (ROI) for detection
|
| 5 |
ROAD_BOUNDARY = (50, 50, 590, 430) # Example: x_min, y_min, x_max, y_max (adjust accordingly)
|
| 6 |
|
| 7 |
-
def
|
| 8 |
"""
|
| 9 |
-
Detects cracks in the given video frame.
|
| 10 |
-
Uses edge detection and contour analysis to detect
|
| 11 |
"""
|
| 12 |
try:
|
| 13 |
# Convert frame to grayscale for crack detection
|
|
@@ -42,7 +42,12 @@ def detect_cracks(frame):
|
|
| 42 |
'confidence': 0.95 # Simulated confidence
|
| 43 |
})
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
except Exception as e:
|
| 47 |
-
print(f"Error in
|
| 48 |
return []
|
|
|
|
| 4 |
# Define road boundary (ROI) for detection
|
| 5 |
ROAD_BOUNDARY = (50, 50, 590, 430) # Example: x_min, y_min, x_max, y_max (adjust accordingly)
|
| 6 |
|
| 7 |
+
def detect_cracks_and_objects(frame):
|
| 8 |
"""
|
| 9 |
+
Detects cracks and objects (potholes) in the given video frame.
|
| 10 |
+
Uses edge detection and contour analysis to detect cracks and objects.
|
| 11 |
"""
|
| 12 |
try:
|
| 13 |
# Convert frame to grayscale for crack detection
|
|
|
|
| 42 |
'confidence': 0.95 # Simulated confidence
|
| 43 |
})
|
| 44 |
|
| 45 |
+
# Detecting other objects (e.g., potholes) in the frame can be added here
|
| 46 |
+
objects = [] # Placeholder for detected objects
|
| 47 |
+
# Object detection logic using custom or pretrained models (e.g., DETR)
|
| 48 |
+
# You can add object detection for potholes here.
|
| 49 |
+
|
| 50 |
+
return cracks + objects
|
| 51 |
except Exception as e:
|
| 52 |
+
print(f"Error in detection: {str(e)}")
|
| 53 |
return []
|