[Bug] Stuck in the pipeline. start (config) phase and unable to return
Camera Model
D405
LibRealSense SDK Version
2.56.94
Firmware Version
5.16.0.1
Operating System
Nvidia Jetson JP5
Kernel Version (Linux Only)
5.15.148-rt-tegra
MIPI Driver Version (NVIDIA Jetson Only)
No response
Platform
NVIDIA Jetson Orin AGX
Connection Type
USB3
Language
Python
Application Segment
None
Issue Description
Turn on two D405 cameras with a resolution of 640 * 480, and then turn on another D435 camera with a resolution of 1280 * 720. When the third camera starts up, it gets stuck on the pipeline. Start. Adjusting the resolution to 640 * 480 is normal. What is the reason for this?
Steps to Reproduce
运行下面的代码,依次启动,左,右手两个相机,然后启动头部相机,测试参数
python3 camera.py \ --camera left \ --width 640 \ --height 480 \ --fps 30 \
python3 camera.py \ --camera right \ --width 640 \ --height 480 \ --fps 30 \ --no-infra
python3 camera.py \ --camera head \ --width 1280 \ --height 720 \ --fps 6 \ --no-infra
`
`
#!/usr/bin/env python3
-- coding: utf-8 --
"""使用 pyrealsense2 直接测试指定 RealSense 相机。
示例: python3 scripts/test_realsense_camera.py --camera left python3 scripts/test_realsense_camera.py --camera right --no-display
按 Ctrl+C 停止。脚本不会创建 ROS 节点,也不会写入 camera_* 共享内存。 """
from future import annotations
import argparse import sys import time
import cv2 import numpy as np import pyrealsense2 as rs
CAMERA_SERIALS = { "right": "真实SN号", "left": "真实SN号", "head": "真实SN号", }
def parse_args(argv=None): parser = argparse.ArgumentParser(description="直接通过 RealSense SDK 测试机器人相机") parser.add_argument( "--camera", required=True, choices=sorted(CAMERA_SERIALS), help="相机位置:right、left、head 或 chest", ) parser.add_argument("--width", type=int, default=1280, help="彩色/深度宽度,默认 1280") parser.add_argument("--height", type=int, default=720, help="彩色/深度高度,默认 720") parser.add_argument("--fps", type=int, default=30, help="帧率,默认 30") parser.add_argument( "--no-infra", action="store_true", help="不启动左右红外流;默认启动红外 1/2", ) parser.add_argument( "--no-display", action="store_true", help="不打开 OpenCV 窗口,仅验证采集并打印帧率", ) parser.add_argument( "--no-auto-exposure", action="store_true", help="关闭自动曝光;默认开启(与项目配置一致)", ) parser.add_argument( "--no-auto-white-balance", action="store_true", help="关闭自动白平衡;默认开启(与项目配置一致)", ) return parser.parse_args(argv)
def build_pipeline(args): serial = CAMERA_SERIALS[args.camera] pipeline = rs.pipeline() config = rs.config() config.enable_device(serial) config.enable_stream(rs.stream.depth, args.width, args.height, rs.format.z16, args.fps) config.enable_stream(rs.stream.color, args.width, args.height, rs.format.bgr8, args.fps) if not args.no_infra: config.enable_stream(rs.stream.infrared, 1, args.width, args.height, rs.format.y8, args.fps) config.enable_stream(rs.stream.infrared, 2, args.width, args.height, rs.format.y8, args.fps) return pipeline, config, serial
def configure_sensor_options(profile, args): """按项目 single_camera_node 的方式设置自动曝光和自动白平衡。""" sensors = profile.get_device().sensors if not sensors: raise RuntimeError("RealSense 设备没有可用 sensor") sensor = sensors[1] if len(sensors) > 1 else sensors[0]
auto_exposure = not args.no_auto_exposure
auto_white_balance = not args.no_auto_white_balance
sensor.set_option(rs.option.enable_auto_exposure, auto_exposure)
sensor.set_option(rs.option.enable_auto_white_balance, auto_white_balance)
print(f"自动曝光: {'开启' if auto_exposure else '关闭'}")
print(f"自动白平衡: {'开启' if auto_white_balance else '关闭'}")def run(args): pipeline, config, serial = build_pipeline(args) align = rs.align(rs.stream.color) started = False frame_count = 0 start_time = time.monotonic()
print(f"位置: {args.camera}")
print(f"SN: {serial}")
print(f"配置: {args.width}x{args.height}@{args.fps}, 红外={'关闭' if args.no_infra else '开启'}")
try:
print('start before')
profile = pipeline.start(config)
print('start after')
started = True
device = profile.get_device()
print(f"连接成功: {device.get_info(rs.camera_info.name)}")
print(f"固件版本: {device.get_info(rs.camera_info.firmware_version)}")
configure_sensor_options(profile, args)
while True:
frames = pipeline.wait_for_frames(timeout_ms=2000)
aligned = align.process(frames)
color_frame = aligned.get_color_frame()
depth_frame = aligned.get_depth_frame()
if not color_frame or not depth_frame:
print("警告:当前帧缺少彩色或深度数据", file=sys.stderr)
continue
color = np.asanyarray(color_frame.get_data())
depth = np.asanyarray(depth_frame.get_data())
frame_count += 1
if not args.no_display:
depth_view = cv2.convertScaleAbs(depth, alpha=0.03)
depth_view = cv2.applyColorMap(depth_view, cv2.COLORMAP_JET)
view = np.hstack((color, depth_view))
cv2.putText(view, f"{args.camera} {serial}", (10, 25),
cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 255, 0), 2)
cv2.imshow("RealSense test (color | depth)", view)
key = cv2.waitKey(1) & 0xFF
if key in (27, ord("q")):
break
elapsed = time.monotonic() - start_time
if elapsed >= 5.0:
print(f"采集正常: {frame_count} 帧, 平均 {frame_count / elapsed:.1f} FPS")
start_time = time.monotonic()
frame_count = 0
finally:
if started:
pipeline.stop()
cv2.destroyAllWindows()
print("相机测试结束")def main(argv=None): args = parse_args(argv) try: run(args) except KeyboardInterrupt: print("\n收到 Ctrl+C,正在退出") except Exception as exc: print(f"相机测试失败: {exc}", file=sys.stderr) return 1 return 0
if name == "main":
raise SystemExit(main())
`
Expected Behavior
No response
Actual Behavior
No response
Relevant Log Output
Additional Context
No response
Source: realsenseai/librealsense