66from pathlib import Path
77from typing import cast
88
9+ import cv2
910import neuracore as nc
1011import numpy as np
1112from common .configs import (
12- CAMERA_LOGGING_NAME ,
1313 GRIPPER_LOGGING_NAME ,
1414 JOINT_NAMES ,
1515 NEUTRAL_JOINT_ANGLES ,
@@ -117,7 +117,7 @@ def main() -> None:
117117 episode = synced_dataset [episode_idx ]
118118
119119 print (f"\n 🚀 Collecting episode { episode_idx } data..." )
120- rgb_images = []
120+ rgb_frames_per_step : list [ dict [ str , np . ndarray ]] = []
121121 parallel_gripper_open_amounts = []
122122 joint_positions = []
123123 for step in tqdm (episode , desc = f"Collecting episode { episode_idx } " ):
@@ -144,11 +144,13 @@ def main() -> None:
144144 gripper_value = gripper_data [GRIPPER_LOGGING_NAME ].open_amount
145145 parallel_gripper_open_amounts .append (gripper_value )
146146
147- # Extract RGB image (just store first one for compatibility)
147+ # Extract RGB for all cameras
148+ step_frames : dict [str , np .ndarray ] = {}
148149 if DataType .RGB_IMAGES in step .data :
149150 rgb_data = step .data [DataType .RGB_IMAGES ]
150- if CAMERA_LOGGING_NAME in rgb_data :
151- rgb_images .append (rgb_data [CAMERA_LOGGING_NAME ].frame )
151+ for camera_name , img_value in rgb_data .items ():
152+ step_frames [camera_name ] = img_value .frame
153+ rgb_frames_per_step .append (step_frames )
152154
153155 joint_positions = np .degrees (np .array (joint_positions ))
154156 parallel_gripper_open_amounts = np .array (parallel_gripper_open_amounts )
@@ -162,8 +164,20 @@ def main() -> None:
162164 robot_controller .set_gripper_open_value (
163165 parallel_gripper_open_amounts [index ]
164166 )
167+
168+ # Display camera frames (dataset stores RGB; OpenCV expects BGR)
169+ if index < len (rgb_frames_per_step ):
170+ for camera_name , frame_rgb in rgb_frames_per_step [index ].items ():
171+ arr = np .asarray (frame_rgb , dtype = np .uint8 )
172+ frame_bgr = cv2 .cvtColor (arr , cv2 .COLOR_RGB2BGR )
173+ cv2 .imshow (f"Replay: { camera_name } " , frame_bgr )
174+ if cv2 .waitKey (1 ) & 0xFF == ord ("q" ):
175+ print ("\n 🛑 'q' pressed, stopping replay..." )
176+ break
177+
165178 end_time = time .time ()
166179 time .sleep (max (0 , 1 / args .frequency - (end_time - start_time )))
180+ cv2 .destroyAllWindows ()
167181 print (f"🎉 Episode { episode_idx } replay completed." )
168182
169183 if args .episode_index == - 1 :
@@ -172,6 +186,7 @@ def main() -> None:
172186 print (f"{ '=' * 60 } " )
173187 except KeyboardInterrupt :
174188 print ("\n 🛑 Keyboard interrupt detected, stopping robot control loop..." )
189+ cv2 .destroyAllWindows ()
175190
176191 robot_controller .stop_control_loop ()
177192 robot_controller .cleanup ()
0 commit comments