live sonar feed, and incremental action feed

This commit is contained in:
kevin
2026-04-16 14:53:01 +08:00
parent cc6cef0f73
commit 34ecc33ee5
28 changed files with 1555 additions and 1227 deletions

View File

@@ -30,6 +30,27 @@ except ImportError:
ZED_AVAILABLE = False
def _open_video_writer(path: Path, fps: float, size: Tuple[int, int]) -> cv2.VideoWriter:
"""Open a VideoWriter, preferring GStreamer NVENC on Jetson for hardware H.264."""
w, h = size
try:
if hasattr(cv2, "CAP_GSTREAMER"):
loc = str(path).replace('"', '\\"')
gst_pipe = (
f'appsrc ! videoconvert ! video/x-raw,format=BGRx ! '
f'nvvidconv ! video/x-raw(memory:NVMM) ! '
f'nvv4l2h264enc bitrate=4000000 ! h264parse ! '
f'mp4mux ! filesink location="{loc}"'
)
writer = cv2.VideoWriter(gst_pipe, cv2.CAP_GSTREAMER, 0, fps, (w, h))
if writer.isOpened():
return writer
writer.release()
except Exception:
pass
return cv2.VideoWriter(str(path), cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
def _parse_weight_json(weight_json: Path) -> Tuple[
Dict[int, Tuple[float, float]],
Optional[float],
@@ -310,7 +331,7 @@ def generate_video(
video_path = images_dir / (output_video_name or f"{svo_name}_preview.mp4")
h, w = frames[0].shape[:2]
writer = cv2.VideoWriter(str(video_path), cv2.VideoWriter_fourcc(*"mp4v"), 10.0, (w, h))
writer = _open_video_writer(video_path, 10.0, (w, h))
for f in frames:
writer.write(f)
writer.release()
@@ -332,7 +353,7 @@ def main():
parser.add_argument("--show-large-labels-at-top-right", action="store_true")
parser.add_argument(
"--summary-star",
action=argparse.BooleanOptionalAction,
action="store_true",
default=False,
help="Whether to draw * on the Final summary line; caller/DB is the source of truth.",
)