Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--num-frames arg for canny/webcam example #1923

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions examples/python/opencv_canny/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -93,7 +98,7 @@ def main() -> None:
"""
)

run_canny()
run_canny(args.num_frames)

rr.script_teardown(args)

Expand Down