python - 如何使用英特尔 realsense d435 创建高度图
问题描述
对不起我的英语不好,我也是这里的新人。
我有一个英特尔 d435 深度摄像头和一个树莓派,还有一辆 diy rc 风格的汽车,我使用车载树莓派运行。我已经在我房间的特定位置放置了 aruco 标记。使用这些和车载网络摄像头,我得到了位置反馈。我编写了一个脚本,使用标记数据的预定义位置使用 aruco 标记使汽车到达所需位置。所以让汽车从a到b不是问题(它沿着直线行驶)。
但现在我希望它从 a 点到 b 点避免静态障碍。
我刚刚了解了 Astar 算法。据我了解,可以绘制从确定起点到确定终点的路径(一般而言)。
所以我想用我的英特尔 d435 相机生成我房间的高度图,并使用 matplotlib 使用 3d 散点图绘制它。我认为这是可能的,因为 d435 可以输出点云数据。但我的编程技能很差,找不到任何显示类似事物的示例。然后可能的计划是到达一个框架,从 3d 数组中获取高度数据,运行 A*,选择所需的节点并驾驶汽车直到它到达那里并重复直到到达目的地。
所以总结一下我的问题是如何使用matplotlib的3d数组和散点图函数从intel d435绘制没有纹理的点云。
import cv2
import numpy as np
import pyrealsense2 as rs
import matplotlib as mpl
import matplotlib.pyplot as plt
import time
from mpl_toolkits.mplot3d import Axes3D
fig1 = plt.figure(1)
ar = fig1.gca(projection='3d')
ar.set_xlim(-1, 1)
ar.set_ylim(-1, 1)
ar.set_zlim(-1, 1)
# Configure depth and color streams
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
# Start streaming
pipe_profile =pipeline.start(config)
points =[[[]]]
def get_3dPoints():#Function to be written
pass
try:
while True:
# Wait for a coherent pair of frames: depth and color
frames = pipeline.wait_for_frames()
depth_frame = frames.get_depth_frame()
color_frame = frames.get_color_frame()
if not depth_frame or not color_frame: #or not infrared_frame:
continue
# Convert images to numpy arrays
depth_image = np.asanyarray(depth_frame.get_data())
color_image = np.asanyarray(color_frame.get_data())
cv2.namedWindow('RealSense', cv2.WINDOW_AUTOSIZE)
colorizer = rs.colorizer()
depth_colormap = np.asanyarray(colorizer.colorize(depth_frame).get_data())
cv2.imshow('RealSense', depth_colormap)
"""
points = get_3dPoints()
tgt = ar.scatter(points, 'red')
ar.set_xlabel('X - axis')
ar.set_ylabel('Y - axis')
ar.set_zlabel('Z - axis')
plt.pause(0.00000000000000001)
tgt.remove()
"""
cv2.waitKey(1)
finally:
# Stop streaming#img = cv2.resize(img, (1280, 720), interpolation=cv2.INTER_AREA)
pipeline.stop()
解决方案
查看此 repo,了解如何获取热图链接
英特尔官方 repo这里也有很多资源
推荐阅读
- javascript - 我可以在 Express POST 请求中进行 DOM 操作吗?
- python - Discord.py - AttributeError:模块'discord'没有属性'Embed'
- django - 如何使用主管和 gunicorn 或 daphne 运行应用程序 django 频道
- javascript - 在角度 6 中修改数组数据后视图未更新
- python - Keras CNN 中用于多类图像分类的验证精度常数
- python - 无法使用 selenium 和 python 获取 cookie
- java - super(variableName) 之间的区别; 和 super.variableName
- mysql - 为什么 MySQL 将浮点 6.099999904632568 截断为 6.1
- css - 查找用户会员计划 WooCommerce
- python-3.x - 在 Python 中使用 HTTP 客户端库时遇到错误