Python mayavi.mlab.orientation_axes() Examples
The following are 6
code examples of mayavi.mlab.orientation_axes().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
mayavi.mlab
, or try the search function
.
Example #1
Source File: regions.py From diluvian with MIT License | 6 votes |
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()
Example #2
Source File: mayavi_viewer.py From Complex-YOLOv3 with GNU General Public License v3.0 | 4 votes |
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
Example #3
Source File: viz_util.py From Geo-CNN with Apache License 2.0 | 4 votes |
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
Example #4
Source File: viz_util.py From reading-frustum-pointnets-code with Apache License 2.0 | 4 votes |
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
Example #5
Source File: regions.py From diluvian with MIT License | 4 votes |
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()
Example #6
Source File: viz_util.py From frustum-pointnets with Apache License 2.0 | 4 votes |
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