简体   繁体   English

Mayavi - 鼠标悬停交互并从不同角度绘制相同场景

[英]Mayavi - Mouse hovering interaction & plot same scene from different perspectives

i am currently struggling to see through how to interact in an appropriate way with a mayavi rendered scene.我目前正在努力了解如何以适当的方式与 Mayavi 渲染场景进行交互。

I have a lidar point cloud which gets plotted by the function points3d(), now i have set in addition a bounding box around a car in between the point cloud, and i would like to change the color of the points inside the box as soon as i hover with my mouse over the bounding box.我有一个由函数points3d()绘制的激光雷达点云,现在我在点云之间的汽车周围另外设置了一个边界框,我想尽快改变框内点的颜色当我将鼠标悬停在边界框上时。 Can you tell me how I can just select the points inside the bbox and change their color?你能告诉我如何只选择 bbox 内的点并改变它们的颜色吗?

And my second question is, how can i show the same scene of the pointcloud in a 3d view and a bird view, concurrently?我的第二个问题是,如何同时在 3d 视图和鸟瞰图中显示相同的点云场景?

Thank you very much :]非常感谢 :]

I have found a solution regarding the color problem - I don't know if it is best practice.我找到了有关颜色问题的解决方案 - 我不知道这是否是最佳实践。 But i still need help for determining the points inside the bounding box.但是我仍然需要帮助来确定边界框内的点。 I would also like to create a gui which enables the user to modify the size and orientation of the bounding box.我还想创建一个 gui,使用户能够修改边界框的大小和方向。 [but that is an other topic] [但那是另一个话题]

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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM