I have been trying to calculate the distances of objects with values of R200 camera. I installed PyRealsense and librealsense(legacy). And examples of PyRealsense are working without any problem.
I have created a code for this purpose:
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)
It returns a matrix that values changing with depending on the position of the object:
[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]
Which column of this matrix is represent distance value or what should I do to calculate the distance.