# After running for a period of time, an error occurs

**URL:** <https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248>\
**Category:** ZED X\
**Tags:** python, sdk, jetson\
**Created:** [October 15, 2024, 7:24am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248 "2024-10-15T07:24:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitPff](https://community.stereolabs.com/user_avatar/community.stereolabs.com/gitpff/32/3502_2.png) [@gitPff](https://community.stereolabs.com/u/gitPff)\
**Post date:** [October 15, 2024, 7:24am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/1 "2024-10-15T07:24:54Z")

</div>

my code

```auto
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

```auto
[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](https://community.stereolabs.com/uploads/short-url/3TgnRQlFa9ve5FNt1WYfAklWr7r.log) (10.7 KB)  
[dmesg\_1.log](https://community.stereolabs.com/uploads/short-url/3TgnRQlFa9ve5FNt1WYfAklWr7r.log) (10.7 KB)  
[dmesg.log](https://community.stereolabs.com/uploads/short-url/5vycyW53KRmQ300XNenk31gdQjU.log) (101.3 KB)

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [October 15, 2024, 9:53am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/2 "2024-10-15T09:53:57Z")

</div>

Hi @gitPff  
Welcome to the [Stereolabs](https://www.stereolabs.com/) community.

Please add information concerning your system:

- host device
- GPU model
- camera model
- ZED SDK version
- etc

---

<div class="post-metadata">

**Author:** ![gitPff](https://community.stereolabs.com/user_avatar/community.stereolabs.com/gitpff/32/3502_2.png) [@gitPff](https://community.stereolabs.com/u/gitPff)\
**Post date:** [October 16, 2024, 6:10am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/3 "2024-10-16T06:10:00Z")

</div>

- 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

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [October 16, 2024, 11:05am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/4 "2024-10-16T11:05:07Z")

</div>

Are you using a [Stereolabs](https://www.stereolabs.com/) ZED Box?

---

<div class="post-metadata">

**Author:** ![gitPff](https://community.stereolabs.com/user_avatar/community.stereolabs.com/gitpff/32/3502_2.png) [@gitPff](https://community.stereolabs.com/u/gitPff)\
**Post date:** [October 17, 2024, 1:51am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/5 "2024-10-17T01:51:41Z")

</div>

no, I using miivii box,[APEX ORIN NX-米文动力科技有限公司](https://www.miivii.com/index.php?s=index/category/index&id=185)  
Miwen Company has made camera adaptation

---

<div class="post-metadata">

**Author:** ![gitPff](https://community.stereolabs.com/user_avatar/community.stereolabs.com/gitpff/32/3502_2.png) [@gitPff](https://community.stereolabs.com/u/gitPff)\
**Post date:** [October 17, 2024, 3:56am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/6 "2024-10-17T03:56:35Z")

</div>

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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [October 17, 2024, 8:01am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/7 "2024-10-17T08:01:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gitPff](https://community.stereolabs.com/user_avatar/community.stereolabs.com/gitpff/32/3502_2.png) [@gitPff](https://community.stereolabs.com/u/gitPff)\
**Post date:** [October 18, 2024, 4:20am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/8 "2024-10-18T04:20:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [October 18, 2024, 3:51pm UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/9 "2024-10-18T15:51:24Z")

</div>

> [@gitPff](#):
>
> ZED\_SDK\_Tegra\_L4T35.3\_v4.1.4.zstd.run

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?

---

<div class="post-metadata">

**Author:** ![gitPff](https://community.stereolabs.com/user_avatar/community.stereolabs.com/gitpff/32/3502_2.png) [@gitPff](https://community.stereolabs.com/u/gitPff)\
**Post date:** [October 28, 2024, 3:09am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/10 "2024-10-28T03:09:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [October 28, 2024, 10:30am UTC](https://community.stereolabs.com/t/after-running-for-a-period-of-time-an-error-occurs/7248/11 "2024-10-28T10:30:46Z")

</div>

You can use the NVIDIA Argus Library
