Hi @mattrouss,
Setup:
I am streaming 2 zed XOne GS cameras from jetson AGX Orin and opening the cameras via pyzed on my laptop.
ZED SDK : 5.1.1
The script I am running on my laptop basically opens the cameras and then calls enable_recording to start SVO recording and disable_recording to stop SVO recording. I notice that when the streaming fails (i.e you kill the streaming script), I am still able to record the SVOs (they are of much smaller size 1.6kb compared to a normal SVO which goes in MBs)
Here a couple of related questions to this topic:
-
I wanted to check if there is any API that I could use to check the heartbeat/ streaming status to ensure that the streaming is running and I am able to receive the frames?
-
When I call enable_recording, I think zed internally calls zed.grab() to grab a frame and then write it to the svo. In contrast, I see that the ZED documentation has an example where it says that grab has to be explicitly called after
enable_recordingis set. I wanted to check what is the right way of doing it?
My code snippet
def start_recording(self, svo_path: Path):
"""
Start SVO recording
:param svo_path: Path to save SVO file
"""
if not self._is_initialized:
_logger.error(f"[{self.name}] Not initialized! Call initialize() first")
return False
_logger.info(f"[{self.name}] Starting recording to {svo_path}")
recording_params = sl.RecordingParameters()
recording_params.compression_mode = sl.SVO_COMPRESSION_MODE.H265_LOSSLESS
recording_params.video_filename = str(svo_path)
recording_params.bitrate = 0
recording_params.target_framerate = self.config.get("fps", 30)
status = sl.CameraOne.enable_recording(recording_params)
if status != sl.ERROR_CODE.SUCCESS:
_logger.error(f"[{self.name}] Failed to start recording: {status}")
return False
_logger.info(f"[{self.name}] Recording started (SDK handling frames internally)")
return True
From the documentation:
def main() :
# Create a ZED camera object
zed = sl.Camera()
# Set initial parameters
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.HD720 # Use HD720 video mode (default fps: 60)
init_params.coordinate_units = sl.UNIT.METER # Set units in meters
# Open the camera
err = zed.open(init_params)
if (err != sl.ERROR_CODE.SUCCESS):
print(repr(err))
exit(-1)
# Enable video recording
record_params = sl.RecordingParameters("myVideoFile.svo")
err = zed.enable_recording(record_params)
if (err != sl.ERROR_CODE.SUCCESS):
print(repr(err))
exit(-1)
# Grab data during 500 frames
i = 0
while i < 500 :
# Grab a new frame
if zed.grab() == sl.ERROR_CODE.SUCCESS:
# Record the grabbed frame in the video file
i = i + 1
zed.disable_recording()
print("Video has been saved ...")
zed.close()
return 0
if __name__ == "__main__" :
main()