如何使用 pyrealsense2 重新启动管道?

问题描述

我购买了英特尔实感 T265 摄像头,正在测试以下示例:

import pyrealsense2 as rs

import cv2

# Get realsense pipeline
pipe = rs.pipeline()

# Configure the pipeline
cfg = rs.config()
cfg.enable_stream(rs.stream.pose) # Positional data (translation,rotation,veLocity etc)

# Start the configured pipeline
pipe.start(cfg)

for _ in range(10):
    frames = pipe.wait_for_frames()
    pose = frames.get_pose_frame()
    if pose:
        data = pose.get_pose_data()
        print('Position: ',data.translation)
    
    else:
        pipe.stop(cfg)

    cv2.waitKey(50)

该示例第一次运行良好,但是当我尝试重新运行它时,它给了我以下 RuntimeError:“No device connected”并引用了“pipe.start(cfg)”行。如果我重新运行脚本,它会再次运行。换句话说,如果我一直点击“F5”来运行脚本,它会工作,崩溃,工作,崩溃等等......

我的问题是,如何重新启动管道,以便在我每次运行脚本时都能识别我的设备?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)