stereolabs / zed-python-api

Python API for the ZED SDK
https://www.stereolabs.com/docs/app-development/python/install/
MIT License
209 stars 95 forks source link

SDK hangs when re-enabling SVO2 recording too frequent #238

Open MartinChowYW opened 1 month ago

MartinChowYW commented 1 month ago

Preliminary Checks

Description

I've been using the SVO2 recording these days and it works flawlessly to produce SVO2 files until I try to create multiple SVO2 files by calling the enable_recording() and disable_recording(). Adding logs messages found that the execution hanged inside the disable_recording() API. And it seems to happen faster if we re-enabling the SVO2 recorder faster.

ps, SVO recorder works fine

Steps to Reproduce

  1. run the provided python script to open the zed camera and start recording e.g. "./SVOTest.pt ${PATH_TO_SVO2_FILE}"
import sys
import pyzed.sl as sl
import time
import os

# Create a ZED camera object
zed = sl.Camera()
zed.open()
# Enable recording with the filename specified in argument
output_path = sys.argv[1]
recordingParameters = sl.RecordingParameters()
recordingParameters.compression_mode = sl.SVO_COMPRESSION_MODE.H264
recordingParameters.video_filename = output_path
err = zed.enable_recording(recordingParameters)

frame_counter = 0
zed.enable_recording(recordingParameters)

while True:
    # Each new frame is added to the SVO file
    print("Before Grab")
    if (zed.grab() == sl.ERROR_CODE.SUCCESS):
        print("Grabbed")
        time.sleep(0.1)
        frame_counter += 1

        if frame_counter == 3:
            print("Disabling recording ......")
            zed.disable_recording()
            print("Disabled recording ......")

            # Reset frame counter
            frame_counter = 0

            print("Enabling SVO recorder")
            zed.enable_recording(recordingParameters)

Expected Result

The SVO recorder should continue to write frame to the SVO2 file

Actual Result

Hanged when calling disable_recording() with if running the provided codes:

ZED Camera model

ZED2i

Environment

aarch64 
SDK 4.1.3
Recorder: SVO2

Anything else?

No response

MartinChowYW commented 1 month ago

I've managed to reproduce it in C++ library too.