Spaces:
Sleeping
Sleeping
Create draw_utils.py
Browse files- draw_utils.py +18 -0
draw_utils.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cv2
|
2 |
+
|
3 |
+
def draw_trajectory(frames, points, output_path, replay=False):
|
4 |
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
5 |
+
height, width, _ = frames[0].shape
|
6 |
+
out = cv2.VideoWriter(output_path, fourcc, 20.0, (width, height))
|
7 |
+
|
8 |
+
for idx, frame in enumerate(frames):
|
9 |
+
if replay:
|
10 |
+
cv2.putText(frame, f"Replay Frame {idx}", (10, 30),
|
11 |
+
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 2)
|
12 |
+
|
13 |
+
for point in points:
|
14 |
+
cv2.circle(frame, point, 8, (0, 0, 255), -1)
|
15 |
+
|
16 |
+
out.write(frame)
|
17 |
+
|
18 |
+
out.release()
|