我目前正在努力了解如何以适当的方式与mayavi渲染的场景进行交互。
我有一个由函数points3d()绘制的激光雷达点云,现在我在点云之间设置了一个围绕汽车的包围框,并且我想在鼠标悬停在边界框上时立即改变框内点的颜色。你能告诉我如何选择bbox内部的点并改变它们的颜色吗?
我的第二个问题是,如何同时在3d视图和鸟视图中显示点云的相同场景?
非常感谢:]
发布于 2019-03-26 12:43:22
我已经找到了解决颜色问题的方法--我不知道这是否是最佳实践。但我仍然需要帮助来确定边界框内的点数。我还想创建一个gui,使用户能够修改包围框的大小和方向。但这是另一个话题
import numpy as np
from mayavi.mlab import draw, points3d
from tvtk.api import tvtk
# Primitives
N = 3000 # Number of points
ones = np.ones(N) #np.hstack((np.tile(np.array([1]), int(N/2)).T, np.tile(np.array([4000]), int(N/2)).T))
scalars = ones #np.arange(N) # Key point: set an integer for each point
# Define color table (including alpha), which must be uint8 and [0,255]
colors = np.vstack((np.tile(np.array([[255],[255],[0]]), int(N/2)).T, np.tile(np.array([[0],[0],[255]]), int(N/2)).T))
# Define coordinates and points
x, y, z = (np.random.random((N, 3))*255).astype(np.uint8).T # Assign x, y, z values to match color
pts = points3d(x, y, z, scale_factor=10) # Create points
#pts.glyph.color_mode = 'color_by_vector' # Color by scalar
# Set look-up table and redraw
#pts.module_manager.scalar_lut_manager.lut.table = colors
pts.glyph.scale_mode = 'scale_by_vector'
sc=tvtk.UnsignedCharArray()
sc.from_array(colors)
pts.mlab_source.dataset.point_data.scalars = sc
draw()https://stackoverflow.com/questions/55343891
复制相似问题