本文整理汇总了Python中mayavi.mlab.orientation_axes方法的典型用法代码示例。如果您正苦于以下问题:Python mlab.orientation_axes方法的具体用法?Python mlab.orientation_axes怎么用?Python mlab.orientation_axes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mayavi.mlab
的用法示例。
在下文中一共展示了mlab.orientation_axes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_body
# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import orientation_axes [as 别名]
def render_body(self):
from mayavi import mlab
body = self.to_body()
mask, bounds = body.get_seeded_component(CONFIG.postprocessing.closing_shape)
fig = mlab.figure(size=(1280, 720))
if self.target is not None:
target_grid = mlab.pipeline.scalar_field(self.target)
target_grid.spacing = CONFIG.volume.resolution
target_grid = mlab.pipeline.iso_surface(target_grid, contours=[0.5], color=(1, 0, 0), opacity=0.1)
grid = mlab.pipeline.scalar_field(mask)
grid.spacing = CONFIG.volume.resolution
mlab.pipeline.iso_surface(grid, color=(0, 1, 0), contours=[0.5], opacity=0.6)
mlab.orientation_axes(figure=fig, xlabel='Z', zlabel='X')
mlab.view(azimuth=45, elevation=30, focalpoint='auto', roll=90, figure=fig)
mlab.show()
示例2: draw_lidar
# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import orientation_axes [as 别名]
def draw_lidar(pc, color=None, fig1=None, bgcolor=(0,0,0), pts_scale=1, pts_mode='point', pts_color=None):
''' Draw lidar points
Args:
pc: numpy array (n,3) of XYZ
color: numpy array (n) of intensity or whatever
fig: mayavi figure handler, if None create new one otherwise will use it
Returns:
fig: created or used fig
'''
#if fig1 is None: fig1 = mlab.figure(figure="point cloud", bgcolor=bgcolor, fgcolor=None, engine=None, size=(1600, 1000))
mlab.clf(figure=None)
if color is None: color = pc[:,2]
mlab.points3d(pc[:,0], pc[:,1], pc[:,2], color, color=pts_color, mode=pts_mode, colormap = 'gnuplot', scale_factor=pts_scale, figure=fig1)
#draw origin
mlab.points3d(0, 0, 0, color=(1,1,1), mode='sphere', scale_factor=0.2)
#draw axis
axes=np.array([
[2.,0.,0.,0.],
[0.,2.,0.,0.],
[0.,0.,2.,0.],
],dtype=np.float64)
mlab.plot3d([0, axes[0,0]], [0, axes[0,1]], [0, axes[0,2]], color=(1,0,0), tube_radius=None, figure=fig1)
mlab.plot3d([0, axes[1,0]], [0, axes[1,1]], [0, axes[1,2]], color=(0,1,0), tube_radius=None, figure=fig1)
mlab.plot3d([0, axes[2,0]], [0, axes[2,1]], [0, axes[2,2]], color=(0,0,1), tube_radius=None, figure=fig1)
# draw fov (todo: update to real sensor spec.)
fov=np.array([ # 45 degree
[20., 20., 0.,0.],
[20.,-20., 0.,0.],
],dtype=np.float64)
mlab.plot3d([0, fov[0,0]], [0, fov[0,1]], [0, fov[0,2]], color=(1,1,1), tube_radius=None, line_width=1, figure=fig1)
mlab.plot3d([0, fov[1,0]], [0, fov[1,1]], [0, fov[1,2]], color=(1,1,1), tube_radius=None, line_width=1, figure=fig1)
# draw square region
TOP_Y_MIN=-20
TOP_Y_MAX=20
TOP_X_MIN=0
TOP_X_MAX=40
TOP_Z_MIN=-2.0
TOP_Z_MAX=0.4
x1 = TOP_X_MIN
x2 = TOP_X_MAX
y1 = TOP_Y_MIN
y2 = TOP_Y_MAX
mlab.plot3d([x1, x1], [y1, y2], [0,0], color=(0.5,0.5,0.5), tube_radius=0.1, line_width=1, figure=fig1)
mlab.plot3d([x2, x2], [y1, y2], [0,0], color=(0.5,0.5,0.5), tube_radius=0.1, line_width=1, figure=fig1)
mlab.plot3d([x1, x2], [y1, y1], [0,0], color=(0.5,0.5,0.5), tube_radius=0.1, line_width=1, figure=fig1)
mlab.plot3d([x1, x2], [y2, y2], [0,0], color=(0.5,0.5,0.5), tube_radius=0.1, line_width=1, figure=fig1)
#mlab.orientation_axes()
mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=60.0, figure=fig1)
return fig1
示例3: draw_lidar
# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import orientation_axes [as 别名]
def draw_lidar(pc, color=None, fig=None, bgcolor=(0,0,0), pts_scale=1, pts_mode='point', pts_color=None):
''' Draw lidar points
Args:
pc: numpy array (n,3) of XYZ
color: numpy array (n) of intensity or whatever
fig: mayavi figure handler, if None create new one otherwise will use it
Returns:
fig: created or used fig
'''
if fig is None: fig = mlab.figure(figure=None, bgcolor=bgcolor, fgcolor=None, engine=None, size=(1600, 1000))
if color is None: color = pc[:,2]
mlab.points3d(pc[:,0], pc[:,1], pc[:,2], color, color=pts_color, mode=pts_mode, colormap = 'gnuplot', scale_factor=pts_scale, figure=fig)
#draw origin
mlab.points3d(0, 0, 0, color=(1,1,1), mode='sphere', scale_factor=0.2)
#draw axis
axes=np.array([
[2.,0.,0.,0.],
[0.,2.,0.,0.],
[0.,0.,2.,0.],
],dtype=np.float64)
mlab.plot3d([0, axes[0,0]], [0, axes[0,1]], [0, axes[0,2]], color=(1,0,0), tube_radius=None, figure=fig)
mlab.plot3d([0, axes[1,0]], [0, axes[1,1]], [0, axes[1,2]], color=(0,1,0), tube_radius=None, figure=fig)
mlab.plot3d([0, axes[2,0]], [0, axes[2,1]], [0, axes[2,2]], color=(0,0,1), tube_radius=None, figure=fig)
# draw fov (todo: update to real sensor spec.)
fov=np.array([ # 45 degree
[20., 20., 0.,0.],
[20.,-20., 0.,0.],
],dtype=np.float64)
mlab.plot3d([0, fov[0,0]], [0, fov[0,1]], [0, fov[0,2]], color=(1,1,1), tube_radius=None, line_width=1, figure=fig)
mlab.plot3d([0, fov[1,0]], [0, fov[1,1]], [0, fov[1,2]], color=(1,1,1), tube_radius=None, line_width=1, figure=fig)
# draw square region
TOP_Y_MIN=-20
TOP_Y_MAX=20
TOP_X_MIN=0
TOP_X_MAX=40
TOP_Z_MIN=-2.0
TOP_Z_MAX=0.4
x1 = TOP_X_MIN
x2 = TOP_X_MAX
y1 = TOP_Y_MIN
y2 = TOP_Y_MAX
mlab.plot3d([x1, x1], [y1, y2], [0,0], color=(0.5,0.5,0.5), tube_radius=0.1, line_width=1, figure=fig)
mlab.plot3d([x2, x2], [y1, y2], [0,0], color=(0.5,0.5,0.5), tube_radius=0.1, line_width=1, figure=fig)
mlab.plot3d([x1, x2], [y1, y1], [0,0], color=(0.5,0.5,0.5), tube_radius=0.1, line_width=1, figure=fig)
mlab.plot3d([x1, x2], [y2, y2], [0,0], color=(0.5,0.5,0.5), tube_radius=0.1, line_width=1, figure=fig)
#mlab.orientation_axes()
mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=62.0, figure=fig)
return fig
示例4: fill_render
# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import orientation_axes [as 别名]
def fill_render(self, model, save_movie=True, **kwargs):
from mayavi import mlab
body = self.to_body()
mask = body.mask
fig = mlab.figure(size=(1280, 720))
if self.target is not None:
target_grid = mlab.pipeline.scalar_field(np.transpose(self.target))
target_grid.spacing = np.flipud(CONFIG.volume.resolution)
target_grid = mlab.pipeline.iso_surface(target_grid, contours=[0.5], color=(1, 0, 0), opacity=0.1)
grid = mlab.pipeline.scalar_field(np.transpose(mask.astype(np.int32)))
grid.spacing = np.flipud(CONFIG.volume.resolution)
contour = mlab.pipeline.iso_surface(grid, color=(0, 1, 0), contours=[0.5], opacity=0.6)
contour.actor.property.backface_culling = True
grid = contour.mlab_source
mlab.orientation_axes(figure=fig)
mlab.view(azimuth=45, elevation=60, focalpoint='auto', figure=fig)
fill_generator = self.fill(model, generator=True, **kwargs)
FRAMES_PER_MOVE = 2
FPS = 60.0
ORBIT_RATE = 0.125
@mlab.animate(delay=int(1000.0/FPS), ui=True)
def animate():
try:
for _, _ in fill_generator:
body = self.to_body()
mask = body.mask
grid.set(scalars=np.transpose(mask.astype(np.int32)))
for _ in range(FRAMES_PER_MOVE):
view = list(mlab.view(figure=fig))
view[0] = (view[0] + ORBIT_RATE * 360.0 / FPS) % 360.0
mlab.view(azimuth=view[0], elevation=view[1], focalpoint='auto')
fig.scene.render()
# fig.scene.movie_maker.animation_step()
yield
except Region.EarlyFillTermination:
pass
fig.scene.movie_maker.record = False
fig.scene.movie_maker.animation_stop()
if save_movie:
fig.scene.movie_maker.record = True
a = animate() # noqa
mlab.show()