After running for a period of time, an error occurs

my code

import sys
import pyzed.sl as sl
import cv2
import numpy as np
import subprocess as sp
import argparse


def ZedVideoCaptureAndPushRTSP(rtsp_url, fps=30, resolution=sl.RESOLUTION.HD1080):
    init_params = sl.InitParameters()
    init_params.camera_fps = fps
    init_params.depth_mode = sl.DEPTH_MODE.NONE
    init_params.camera_resolution = resolution

    zed_camera = sl.Camera()
    status = zed_camera.open(init_params)
    if status != sl.ERROR_CODE.SUCCESS:
        print(f"Failed to open camera: {repr(status)}")
        sys.exit(1)

    zed_image = sl.Mat()

    # FFmpeg命令,用于推送到RTSP服务器
    ffmpeg_cmd = [
        'ffmpeg',
        '-y',
        '-f', 'rawvideo',
        '-vcodec', 'rawvideo',
        '-pix_fmt', 'bgr24',  # 假设ZED SDK输出BGR格式
        '-s', '1920x1080',
        '-r', str(fps),
        '-i', '-',
        '-tune', 'zerolatency',
        '-preset', 'ultrafast',
        '-g', '1',  # 关键帧间隔设置为1,可能需要根据实际情况调整
        '-c:v', 'h264_nvmpi',
        '-pix_fmt', 'yuv420p',
        '-f', 'rtsp',
        rtsp_url
    ]

    ffmpeg_process = sp.Popen(ffmpeg_cmd, stdin=sp.PIPE, stdout=sp.DEVNULL, stderr=sp.PIPE)

    try:
        while True:
            status = zed_camera.grab()
            if status == sl.ERROR_CODE.SUCCESS:
                zed_camera.retrieve_image(zed_image, sl.VIEW.SIDE_BY_SIDE)  # 假设我们只使用左目图像

                zed_image_data = np.array(zed_image.get_data(), dtype=np.uint8)
                zed_image_data = cv2.cvtColor(zed_image_data, cv2.COLOR_BGR2RGB)
                zed_image_data = cv2.resize(zed_image_data, (
                1920, 1080), interpolation=cv2.INTER_AREA)
                zed_image_data = zed_image_data.tobytes()
                # 写入FFmpeg进程
                ffmpeg_process.stdin.write(zed_image_data)
                ffmpeg_process.stdin.flush()  # 确保数据尽快发送到FFmpeg
            else:
                print(f"Failed to grab frame: {repr(status)}")
                break
    finally:
        zed_camera.close()
        ffmpeg_process.stdin.close()
        ffmpeg_process.wait()
        # cv2.destroyAllWindows()  # 如果不再显示视频帧,可以移除这行代码


# 解析命令行参数
if __name__ == '__main__':
    resolution = sl.RESOLUTION.HD1080

    ZedVideoCaptureAndPushRTSP('rtsp://192.168.1.27/live/test_stream', 30, resolution)

# gst-launch-1.0 playbin uri=rtsp://192.168.1.27/live/test_stream ! videoconvert ! autovideosink

my error

[2024-10-14 16:51:49 UTC][ZED][INFO] Logging level INFO
[2024-10-14 16:51:50 UTC][ZED][WARNING] CAMERA NOT DETECTED in sl::ERROR_CODE sl::Camera::open(sl::InitParameters)
Failed to open camera: CAMERA NOT DETECTED
[2024-10-14 16:51:51 UTC][ZED][ERROR] [ZED] sl::Camera::Open has not been called, no Camera instance running.
[2024-10-14 16:51:51 UTC][ZED][ERROR] [ZED] sl::Camera::Open has not been called, no Camera instance running.

dmesg_1.log (10.7 KB)
dmesg_1.log (10.7 KB)
dmesg.log (101.3 KB)

Hi @gitPff
Welcome to the Stereolabs community.

Please add information concerning your system:

  • host device
  • GPU model
  • camera model
  • ZED SDK version
  • etc
  • host device:jetson orin nx 8G

  • Jetpack model: Jetpack 5.1.1

  • camera model:zed x

  • L4T:# R35 (release), REVISION: 3.1, GCID: 32827747, BOARD: t186ref, EABI: aarch64, DATE: Sun Mar 19 15:19:21 UTC 2023

  • ZED SDK version:ZED_SDK_Tegra_L4T35.3_v4.1.4.zstd.run

Are you using a Stereolabs ZED Box?

no, I using miivii box,APEX ORIN NX-米文动力科技有限公司
Miwen Company has made camera adaptation

My ultimate goal is to obtain video data from binocular cameras, but the video data will be changed to 1920x1080 and pushed to the streaming server in the form of RTSP. My code is as follows, can you help me check the problem, please

import sys
import pyzed.sl as sl
import cv2
import numpy as np
import subprocess as sp
import argparse


def ZedVideoCaptureAndPushRTSP(rtsp_url, fps=30, resolution=sl.RESOLUTION.HD1080):
    init_params = sl.InitParameters()
    init_params.camera_fps = fps
    init_params.depth_mode = sl.DEPTH_MODE.NONE
    init_params.camera_resolution = resolution

    zed_camera = sl.Camera()
    status = zed_camera.open(init_params)
    if status != sl.ERROR_CODE.SUCCESS:
        print(f"Failed to open camera: {repr(status)}")
        sys.exit(1)

    zed_image = sl.Mat()

    # FFmpeg命令,用于推送到RTSP服务器
    ffmpeg_cmd = [
        'ffmpeg',
        '-y',
        '-f', 'rawvideo',
        '-vcodec', 'rawvideo',
        '-pix_fmt', 'rgb24',
        '-s', '1920x1080',
        '-r', str(fps),
        '-i', '-',
        '-tune', 'zerolatency',
        '-preset', 'ultrafast',
        '-g', '1',  # 关键帧间隔设置为1,可能需要根据实际情况调整
        '-c:v', 'h264_nvmpi',
        '-pix_fmt', 'yuv420p',
        '-f', 'rtsp',
        rtsp_url
    ]

    ffmpeg_process = sp.Popen(ffmpeg_cmd, stdin=sp.PIPE, stdout=sp.DEVNULL, stderr=sp.PIPE)

    try:
        while True:
            status = zed_camera.grab()
            if status == sl.ERROR_CODE.SUCCESS:
                zed_camera.retrieve_image(zed_image, sl.VIEW.SIDE_BY_SIDE)
                zed_image_data = np.array(zed_image.get_data(), dtype=np.uint8)
                zed_image_data = cv2.cvtColor(zed_image_data, cv2.COLOR_BGR2RGB)
                zed_image_data = cv2.resize(zed_image_data, (
                1920, 1080), interpolation=cv2.INTER_AREA)
                # zed_image_data = zed_image_data.tobytes()
                ffmpeg_process.stdin.write(zed_image_data)
                ffmpeg_process.stdin.flush()  
            else:
                print(f"Failed to grab frame: {repr(status)}")
                break
    finally:
        # out.relaease()
        zed_camera.close()
        ffmpeg_process.stdin.close()
        ffmpeg_process.wait()
        cv2.destroyAllWindows()  # 如果不再显示视频帧,可以移除这行代码


# 解析命令行参数
if __name__ == '__main__':
    resolution = sl.RESOLUTION.HD1080

    ZedVideoCaptureAndPushRTSP('rtsp://192.168.1.27/live/test_stream', 30, resolution)
type or paste code here

What ZED X Driver are you using?
Did you install our drivers or did you get them from MiiVii?

The driver program I installed myself, ZED_SDK_Tegra_L4T35.3_v4.1.4.zstd.run
All tools within the driver program can be used normally

This is the ZED SDK, not the ZED X Driver.

You are using ZED X driver v0.6.4 that is old.
Can you contact MiiVii to ask if they have an available never driver compatible with their device?

thank you。
How can I obtain a pure video stream without depth information,please~

You can use the NVIDIA Argus Library