Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,45 @@ from datetime import datetime
|
|
11 |
from collections import Counter
|
12 |
from typing import Any, Dict, List, Optional, Tuple
|
13 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Suppress Ultralytics warning by setting a writable config directory
|
16 |
os.environ["YOLO_CONFIG_DIR"] = "/tmp/Ultralytics"
|
|
|
11 |
from collections import Counter
|
12 |
from typing import Any, Dict, List, Optional, Tuple
|
13 |
import numpy as np
|
14 |
+
import cv2
|
15 |
+
import time
|
16 |
+
|
17 |
+
def process_sequential(frame: np.ndarray):
|
18 |
+
# Detect bridge piers first
|
19 |
+
detections, annotated_frame = process_bridge_piers(frame)
|
20 |
+
cv2.imshow("Bridge Piers Detection", annotated_frame)
|
21 |
+
cv2.waitKey(1) # Wait for a short time (e.g., 1 ms)
|
22 |
+
time.sleep(1) # Pause for 1 second for the user to see the result
|
23 |
+
|
24 |
+
# Replay the video (or go to next frame if real-time processing)
|
25 |
+
cv2.imshow("Bridge Piers Detection", frame)
|
26 |
+
cv2.waitKey(1)
|
27 |
+
|
28 |
+
# Detect culverts next
|
29 |
+
detections, annotated_frame = process_culverts(frame)
|
30 |
+
cv2.imshow("Culverts Detection", annotated_frame)
|
31 |
+
cv2.waitKey(1)
|
32 |
+
time.sleep(1)
|
33 |
+
|
34 |
+
# Replay the video for culverts detection
|
35 |
+
cv2.imshow("Culverts Detection", frame)
|
36 |
+
cv2.waitKey(1)
|
37 |
+
|
38 |
+
# Detect earthwork activities
|
39 |
+
detections, annotated_frame = process_earthwork(frame)
|
40 |
+
cv2.imshow("Earthwork Detection", annotated_frame)
|
41 |
+
cv2.waitKey(1)
|
42 |
+
time.sleep(1)
|
43 |
+
|
44 |
+
# Replay the video for earthwork detection
|
45 |
+
cv2.imshow("Earthwork Detection", frame)
|
46 |
+
cv2.waitKey(1)
|
47 |
+
|
48 |
+
# Add more steps if needed...
|
49 |
+
|
50 |
+
cv2.waitKey(0) # Wait for a key press to close the window after detection
|
51 |
+
cv2.destroyAllWindows()
|
52 |
+
|
53 |
|
54 |
# Suppress Ultralytics warning by setting a writable config directory
|
55 |
os.environ["YOLO_CONFIG_DIR"] = "/tmp/Ultralytics"
|