From b83034dbd6519ed95a54f73cb7f35c927a90f561 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 19 Apr 2023 14:45:25 +0200 Subject: [PATCH] --num-frames arg for canny example --- examples/python/opencv_canny/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/python/opencv_canny/main.py b/examples/python/opencv_canny/main.py index 6220d7ef1c9f..05c2b7342f56 100755 --- a/examples/python/opencv_canny/main.py +++ b/examples/python/opencv_canny/main.py @@ -22,18 +22,22 @@ """ import argparse +from typing import Optional import cv2 import rerun as rr -def run_canny() -> None: +def run_canny(num_frames: Optional[int]) -> None: # Create a new video capture cap = cv2.VideoCapture(0) frame_nr = 0 while cap.isOpened(): + if num_frames and frame_nr >= num_frames: + break + # Read the frame ret, img = cap.read() if not ret: @@ -66,6 +70,7 @@ def main() -> None: parser.add_argument( "--device", type=int, default=0, help="Which camera device to use. (Passed to `cv2.VideoCapture()`)" ) + parser.add_argument("--num-frames", type=int, default=None, help="The number of frames to log") rr.script_add_args(parser) args = parser.parse_args() @@ -93,7 +98,7 @@ def main() -> None: """ ) - run_canny() + run_canny(args.num_frames) rr.script_teardown(args)