1111logger = logging .getLogger (__name__ )
1212zed_app = typer .Typer (help = "CLI tools for the ZED camera module of rcs." )
1313
14- DEFAULT_RGB_SNAPSHOT_OUTPUT_OPTION = typer .Option (Path ("zed_latest.png" ), "--output" , "-o" , help = "PNG file to write." )
15-
1614
1715def _display_frame (window_name : str , frame ):
1816 cv2 .imshow (window_name , frame .camera .color .data [:, :, ::- 1 ])
@@ -97,17 +95,18 @@ def rgb_view(
9795@zed_app .command ("rgb-snapshot" )
9896def rgb_snapshot (
9997 serial : str | None = typer .Argument (None , help = "Optional ZED serial number. Uses the first device if omitted." ),
100- output : Path = DEFAULT_RGB_SNAPSHOT_OUTPUT_OPTION ,
98+ output : str = typer . Option ( "zed_latest.png" , "--output" , "-o" , help = "PNG file to write." ) ,
10199 width : int = typer .Option (1280 , help = "Requested capture width." ),
102100 height : int = typer .Option (720 , help = "Requested capture height." ),
103101 fps : int = typer .Option (30 , help = "Requested capture frame rate." ),
104102 duration : float = typer .Option (1.0 , "--duration" , "-d" , help = "Seconds to read frames before saving." ),
105103):
106104 """Open a ZED camera briefly and save the latest RGB frame as a PNG."""
105+ output_path = Path (output )
107106 if duration <= 0 :
108107 msg = "Duration must be greater than zero."
109108 raise typer .BadParameter (msg )
110- if output .suffix .lower () != ".png" :
109+ if output_path .suffix .lower () != ".png" :
111110 msg = "Output path must end in .png."
112111 raise typer .BadParameter (msg )
113112
@@ -131,11 +130,11 @@ def rgb_snapshot(
131130 camera .close ()
132131
133132 assert latest_frame is not None
134- output .parent .mkdir (parents = True , exist_ok = True )
133+ output_path .parent .mkdir (parents = True , exist_ok = True )
135134 image_bgr = latest_frame .camera .color .data [:, :, ::- 1 ]
136135 print (latest_frame .camera .color .intrinsics )
137- if not cv2 .imwrite (str (output ), image_bgr ):
138- msg = f"Could not write PNG to { output } ."
136+ if not cv2 .imwrite (str (output_path ), image_bgr ):
137+ msg = f"Could not write PNG to { output_path } ."
139138 raise typer .BadParameter (msg )
140139
141140 typer .echo (f"Saved { output } from ZED { serial } after reading { frames_read } frame(s)." )
0 commit comments