INSTALL
1.pip install pyrealsense2(必须是python2.7,这里如果觉得安装很慢,请先下载.whl文件然后在install)
2.安装sdk(https://github.com/IntelRealSense/librealsense/releases/tag/v2.16.1)
使用
查看深度信息并显示
import pyrealsense2 as rs
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib.colors import LogNorm
try:
pipeline = rs.pipeline()
pipeline.start()
while True:
frames = pipeline.wait_for_frames()
depth = frames.get_depth_frame()
depth_data = depth.as_frame().get_data()
np_image = np.asanyarray(depth_data)
break
except Exception as e:
print e
print np_image.shape
plt.imshow(np_image, cmap=cm.hot, norm=LogNorm())
plt.colorbar()
plt.show()