跳到主要内容
版本:1.0.0

XenseSDK 快速开始

下面的程序通过序列号连接传感器,并在同一次采集中获取校正图和深度图:

from time import sleep
from xensesdk import Sensor


def main():
# 也可以传入相机编号 0/1,或远程连接时传入 mac_addr
sensor = Sensor.create("OP000064", use_gpu=True)
try:
while True:
rectify, depth = sensor.selectSensorInfo(
Sensor.OutputType.Rectify,
Sensor.OutputType.Depth,
)
if rectify is not None:
print("rectify:", rectify.shape, rectify.dtype)
if depth is not None:
print("depth:", depth.shape, depth.dtype)
sleep(0.02)
finally:
sensor.release()


if __name__ == "__main__":
main()

选择连接方式​

Sensor.create(0) # 本地相机编号
Sensor.create("OP000064") # 传感器序列号
Sensor.create("OP000064", mac_addr="...") # 算力板上的远程传感器
Sensor.create(None, video_path="sample.mp4") # 离线视频

不要在多个线程中重复创建同一个传感器。长时间运行时,请在 finally 中释放实例,避免摄像头句柄和推理线程泄漏。