我一直在尝试用 R200 相机的值计算物体的距离。我安装了 PyRealsense 和 librealsense(legacy)。PyRealsense 的示例可以正常工作。
为此,我创建了一个代码:
import pyrealsense as pyrs
from pyrealsense.constants import rs_option
depth_stream = pyrs.stream.DepthStream()
infrared_stream = pyrs.stream.InfraredStream()
with pyrs.Service() as serv:
with serv.Device(streams=(depth_stream, infrared_stream, )) as dev:
#dev.apply_ivcam_preset(0)
while True:
dev.wait_for_frames()
print(dev.infrared)
它返回一个矩阵,其值根据对象的位置而变化:
[37 37 39 ... 20 20 21]
[35 35 38 ... 17 18 19]
[34 33 37 ... 19 20 20]]
[[40 36 30 ... 16 15 17]
[40 37 28 ... 14 14 19]
[42 39 28 ... 14 16 20]
这个矩阵的哪一列代表距离值或者我应该怎么做来计算距离。