Python mayavi.mlab.figure() Examples
The following are 30
code examples of mayavi.mlab.figure().
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: read_grasps_from_file.py From PointNetGPD with MIT License | 6 votes |
def display_gripper_on_object(obj_, grasp_): """display both object and gripper using mayavi""" # transfer wrong was fixed by the previews comment of meshpy modification. # gripper_name = 'robotiq_85' # home_dir = os.environ['HOME'] # gripper = RobotGripper.load(gripper_name, home_dir + "/code/grasp-pointnet/dex-net/data/grippers") # stable_pose = self.dataset.stable_pose(object.key, 'pose_1') # T_obj_world = RigidTransform(from_frame='obj', to_frame='world') t_obj_gripper = grasp_.gripper_pose(gripper) stable_pose = t_obj_gripper grasp_ = grasp_.perpendicular_table(stable_pose) Vis.figure(bgcolor=(1, 1, 1), size=(1000, 1000)) Vis.gripper_on_object(gripper, grasp_, obj_, gripper_color=(0.25, 0.25, 0.25), # stable_pose=stable_pose, # .T_obj_world, plot_table=False) Vis.show()
Example #2
Source File: utils.py From cvml_project with MIT License | 6 votes |
def draw_gt_boxes3d(gt_boxes3d, fig, color=(1, 1, 1)): """ Draw 3D bounding boxes Args: gt_boxes3d: numpy array (3,8) for XYZs of the box corners fig: figure handler color: RGB value tuple in range (0,1), box line color """ for k in range(0, 4): i, j = k, (k + 1) % 4 mlab.plot3d([gt_boxes3d[0, i], gt_boxes3d[0, j]], [gt_boxes3d[1, i], gt_boxes3d[1, j]], [gt_boxes3d[2, i], gt_boxes3d[2, j]], tube_radius=None, line_width=2, color=color, figure=fig) i, j = k + 4, (k + 1) % 4 + 4 mlab.plot3d([gt_boxes3d[0, i], gt_boxes3d[0, j]], [gt_boxes3d[1, i], gt_boxes3d[1, j]], [gt_boxes3d[2, i], gt_boxes3d[2, j]], tube_radius=None, line_width=2, color=color, figure=fig) i, j = k, k + 4 mlab.plot3d([gt_boxes3d[0, i], gt_boxes3d[0, j]], [gt_boxes3d[1, i], gt_boxes3d[1, j]], [gt_boxes3d[2, i], gt_boxes3d[2, j]], tube_radius=None, line_width=2, color=color, figure=fig) return fig
Example #3
Source File: viz_util.py From frustum-pointnets with Apache License 2.0 | 6 votes |
def draw_lidar_simple(pc, color=None): ''' Draw lidar points. simplest set up. ''' fig = mlab.figure(figure=None, bgcolor=(0,0,0), fgcolor=None, engine=None, size=(1600, 1000)) if color is None: color = pc[:,2] #draw points mlab.points3d(pc[:,0], pc[:,1], pc[:,2], color, color=None, mode='point', colormap = 'gnuplot', scale_factor=1, 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) mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=62.0, figure=fig) return fig
Example #4
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 #5
Source File: viz_util.py From reading-frustum-pointnets-code with Apache License 2.0 | 6 votes |
def draw_lidar_simple(pc, color=None): ''' Draw lidar points. simplest set up. ''' fig = mlab.figure(figure=None, bgcolor=(0,0,0), fgcolor=None, engine=None, size=(1600, 1000)) if color is None: color = pc[:,2] #draw points mlab.points3d(pc[:,0], pc[:,1], pc[:,2], color, color=None, mode='point', colormap = 'gnuplot', scale_factor=1, 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) mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=62.0, figure=fig) return fig
Example #6
Source File: utils.py From tf-3d-object-detection with MIT License | 6 votes |
def viz(pc, centers, corners_3d, pc_origin): import mayavi.mlab as mlab fig = mlab.figure(figure=None, bgcolor=(0.4, 0.4, 0.4), fgcolor=None, engine=None, size=(500, 500)) mlab.points3d(pc[:, 0], pc[:, 1], pc[:, 2], mode='sphere', colormap='gnuplot', scale_factor=0.1, figure=fig) mlab.points3d(centers[:, 0], centers[:, 1], centers[:, 2], mode='sphere', color=(1, 0, 1), scale_factor=0.3, figure=fig) mlab.points3d(corners_3d[:, 0], corners_3d[:, 1], corners_3d[:, 2], mode='sphere', color=(1, 1, 0), scale_factor=0.3, figure=fig) mlab.points3d(pc_origin[:, 0], pc_origin[:, 1], pc_origin[:, 2], mode='sphere', color=(0, 1, 0), scale_factor=0.05, figure=fig) ''' Green points are original PC from KITTI White points are PC feed into the network Red point is the predicted center Yellow point the post-processed predicted bounding box corners ''' raw_input("Press any key to continue")
Example #7
Source File: mayavi_viewer.py From Complex-YOLOv3 with GNU General Public License v3.0 | 6 votes |
def draw_lidar_simple(pc, color=None): ''' Draw lidar points. simplest set up. ''' fig = mlab.figure(figure=None, bgcolor=(0,0,0), fgcolor=None, engine=None, size=(1600, 1000)) if color is None: color = pc[:,2] #draw points mlab.points3d(pc[:,0], pc[:,1], pc[:,2], color, color=None, mode='point', colormap = 'gnuplot', scale_factor=1, 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) mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=62.0, figure=fig) return fig
Example #8
Source File: viz_util.py From Geo-CNN with Apache License 2.0 | 6 votes |
def draw_lidar_simple(pc, color=None): ''' Draw lidar points. simplest set up. ''' fig = mlab.figure(figure=None, bgcolor=(0,0,0), fgcolor=None, engine=None, size=(1600, 1000)) if color is None: color = pc[:,2] #draw points mlab.points3d(pc[:,0], pc[:,1], pc[:,2], color, color=None, mode='point', colormap = 'gnuplot', scale_factor=1, 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) mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=62.0, figure=fig) return fig
Example #9
Source File: visualise.py From OpenModes with GNU General Public License v3.0 | 5 votes |
def plot_parts(parts, figsize=(10, 4), view_angles = (40, 90)): """Create a simple 3D plot to show the location of loaded parts in space Parameters ---------- parts : list of `Mesh` or `Part` The parts to plot figsize : tuple, optional The figsize (in inches) which will be passed to matplotlib viewangles : tuple, optional The viewing angle of the 3D plot in degrees, will be passed to matplotlib Requires that matplotlib is installed """ import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure(figsize=figsize) ax = fig.add_subplot(111, projection='3d') for part in parts.iter_single(): mesh = part.mesh for edge in mesh.get_edges(): nodes = part.nodes[edge] ax.plot(nodes[:, 0], nodes[:, 1], nodes[:, 2], 'k') ax.view_init(*view_angles) ax.autoscale() plt.show()
Example #10
Source File: Cal_norm.py From PointNetGPD with MIT License | 5 votes |
def show_pcl_norm(grasp_bottom_center, normal_, color='r', clear=False): if clear: plt.figure() plt.clf() plt.gcf() plt.ion() ax = plt.gca(projection='3d') un1 = grasp_bottom_center + 0.5 * normal_ * 0.05 ax.scatter(un1[0], un1[1], un1[2], marker='x', c=color) un2 = grasp_bottom_center ax.scatter(un2[0], un2[1], un2[2], marker='^', c='g') ax.plot([un1[0], un2[0]], [un1[1], un2[1]], [un1[2], un2[2]], 'b-', linewidth=1) # bi normal
Example #11
Source File: forward.py From conpy with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _plot_coord_system(points, dim1, dim2, dim3, scale=0.001, n_ori=3): """Useful for checking the results of _make_radial_coord_system. Usage: >>> _, origin = _fit_sphere(fwd['source_rr']) ... rad, tan1, tan2 = _make_radial_coord_system(fwd['source_rr'], origin) ... _plot_coord_system(fwd['source_rr'], rad, tan1, tan2) Use ``scale`` to control the size of the arrows. """ from mayavi import mlab f = mlab.figure(size=(600, 600)) red, blue, black = (1, 0, 0), (0, 0, 1), (0, 0, 0) if n_ori == 3: mlab.quiver3d(points[:, 0], points[:, 1], points[:, 2], dim1[:, 0], dim1[:, 1], dim1[:, 2], scale_factor=scale, color=red) if n_ori > 1: mlab.quiver3d(points[:, 0], points[:, 1], points[:, 2], dim2[:, 0], dim2[:, 1], dim2[:, 2], scale_factor=scale, color=blue) mlab.quiver3d(points[:, 0], points[:, 1], points[:, 2], dim3[:, 0], dim3[:, 1], dim3[:, 2], scale_factor=scale, color=black) return f
Example #12
Source File: viz_util.py From reading-frustum-pointnets-code with Apache License 2.0 | 5 votes |
def draw_gt_boxes3d(gt_boxes3d, fig, color=(1,1,1), line_width=1, draw_text=True, text_scale=(1,1,1), color_list=None): ''' Draw 3D bounding boxes Args: gt_boxes3d: numpy array (n,8,3) for XYZs of the box corners fig: mayavi figure handler color: RGB value tuple in range (0,1), box line color line_width: box line width draw_text: boolean, if true, write box indices beside boxes text_scale: three number tuple color_list: a list of RGB tuple, if not None, overwrite color. Returns: fig: updated fig ''' num = len(gt_boxes3d) for n in range(num): b = gt_boxes3d[n] if color_list is not None: color = color_list[n] if draw_text: mlab.text3d(b[4,0], b[4,1], b[4,2], '%d'%n, scale=text_scale, color=color, figure=fig) for k in range(0,4): #http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html i,j=k,(k+1)%4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) i,j=k+4,(k+1)%4 + 4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) i,j=k,k+4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) #mlab.show(1) #mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=62.0, figure=fig) return fig
Example #13
Source File: view_results.py From reading-frustum-pointnets-code with Apache License 2.0 | 5 votes |
def show_lidar_with_boxes(pc_velo, objects, calib, img_fov=False, img_width=None, img_height=None): ''' Show all LiDAR points. Draw 3d box in LiDAR point cloud (in velo coord system) ''' if 'mlab' not in sys.modules: import mayavi.mlab as mlab from viz_util import draw_lidar_simple, draw_lidar, draw_gt_boxes3d print(('All point num: ', pc_velo.shape[0])) fig = mlab.figure(figure=None, bgcolor=(0,0,0), fgcolor=None, engine=None, size=(1000, 500)) if img_fov: pc_velo = get_lidar_in_image_fov(pc_velo, calib, 0, 0, img_width, img_height) print(('FOV point num: ', pc_velo.shape[0])) draw_lidar(pc_velo, fig=fig) for obj in objects: if obj.type=='DontCare':continue # Draw 3d bounding box box3d_pts_2d, box3d_pts_3d = utils.compute_box_3d(obj, calib.P) box3d_pts_3d_velo = calib.project_rect_to_velo(box3d_pts_3d) # Draw heading arrow ori3d_pts_2d, ori3d_pts_3d = utils.compute_orientation_3d(obj, calib.P) ori3d_pts_3d_velo = calib.project_rect_to_velo(ori3d_pts_3d) x1,y1,z1 = ori3d_pts_3d_velo[0,:] x2,y2,z2 = ori3d_pts_3d_velo[1,:] draw_gt_boxes3d([box3d_pts_3d_velo], fig=fig) mlab.plot3d([x1, x2], [y1, y2], [z1,z2], color=(0.5,0.5,0.5), tube_radius=None, line_width=1, figure=fig) mlab.show(1)
Example #14
Source File: kitti_object.py From reading-frustum-pointnets-code with Apache License 2.0 | 5 votes |
def show_lidar_with_boxes(pc_velo, objects, calib, img_fov=False, img_width=None, img_height=None): ''' Show all LiDAR points. Draw 3d box in LiDAR point cloud (in velo coord system) ''' #显示所有激光雷达点。在LiDAR point cloud中绘制3d box(在velo coord系统中) -H if 'mlab' not in sys.modules: import mayavi.mlab as mlab from viz_util import draw_lidar_simple, draw_lidar, draw_gt_boxes3d print(('All point num: ', pc_velo.shape[0])) fig = mlab.figure(figure=None, bgcolor=(0,0,0), fgcolor=None, engine=None, size=(1000, 500)) if img_fov: pc_velo = get_lidar_in_image_fov(pc_velo, calib, 0, 0, img_width, img_height) print(('FOV point num: ', pc_velo.shape[0])) draw_lidar(pc_velo, fig=fig) for obj in objects: if obj.type=='DontCare':continue # Draw 3d bounding box box3d_pts_2d, box3d_pts_3d = utils.compute_box_3d(obj, calib.P) box3d_pts_3d_velo = calib.project_rect_to_velo(box3d_pts_3d) # Draw heading arrow ori3d_pts_2d, ori3d_pts_3d = utils.compute_orientation_3d(obj, calib.P) ori3d_pts_3d_velo = calib.project_rect_to_velo(ori3d_pts_3d) x1,y1,z1 = ori3d_pts_3d_velo[0,:] x2,y2,z2 = ori3d_pts_3d_velo[1,:] draw_gt_boxes3d([box3d_pts_3d_velo], fig=fig) mlab.plot3d([x1, x2], [y1, y2], [z1,z2], color=(0.5,0.5,0.5), tube_radius=None, line_width=1, figure=fig) mlab.show(1)
Example #15
Source File: test_horseshoe.py From OpenModes with GNU General Public License v3.0 | 5 votes |
def test_surface_normals(plot=False, skip_asserts=False, write_reference=False): "Test the surface normals of a horseshoe mesh" sim = openmodes.Simulation() mesh = sim.load_mesh(osp.join(mesh_dir, 'horseshoe_rect.msh')) part = sim.place_part(mesh) basis = sim.basis_container[part] r, rho = basis.integration_points(mesh.nodes, triangle_centres) normals = mesh.surface_normals r = r.reshape((-1, 3)) if write_reference: write_2d_real(osp.join(reference_dir, 'surface_r.txt'), r) write_2d_real(osp.join(reference_dir, 'surface_normals.txt'), normals) r_ref = read_2d_real(osp.join(reference_dir, 'surface_r.txt')) normals_ref = read_2d_real(osp.join(reference_dir, 'surface_normals.txt')) if not skip_asserts: assert_allclose(r, r_ref) assert_allclose(normals, normals_ref) if plot: from mayavi import mlab mlab.figure() mlab.quiver3d(r[:, 0], r[:, 1], r[:, 2], normals[:, 0], normals[:, 1], normals[:, 2], mode='cone') mlab.view(distance='auto') mlab.show()
Example #16
Source File: test_horseshoe.py From OpenModes with GNU General Public License v3.0 | 5 votes |
def test_extinction(plot_extinction=False, skip_asserts=False, write_reference=False): "Test extinction of a horseshoe" sim = openmodes.Simulation(name='horseshoe_extinction', basis_class=openmodes.basis.LoopStarBasis) shoe = sim.load_mesh(osp.join(mesh_dir, 'horseshoe_rect.msh')) sim.place_part(shoe) num_freqs = 101 freqs = np.linspace(1e8, 20e9, num_freqs) extinction = np.empty(num_freqs, np.complex128) e_inc = np.array([1, 0, 0], dtype=np.complex128) k_hat = np.array([0, 0, 1], dtype=np.complex128) pw = PlaneWaveSource(e_inc, k_hat) for freq_count, s in sim.iter_freqs(freqs): Z = sim.impedance(s) V = sim.source_vector(pw, s) extinction[freq_count] = np.vdot(V, Z.solve(V)) if write_reference: # generate the reference extinction solution write_1d_complex(osp.join(reference_dir, 'extinction.txt'), extinction) extinction_ref = read_1d_complex(osp.join(reference_dir, 'extinction.txt')) if not skip_asserts: assert_allclose(extinction, extinction_ref, rtol=1e-3) if plot_extinction: # to plot the generated and reference solutions plt.figure() plt.plot(freqs*1e-9, extinction.real) plt.plot(freqs*1e-9, extinction_ref.real, '--') plt.plot(freqs*1e-9, extinction.imag) plt.plot(freqs*1e-9, extinction_ref.imag, '--') plt.xlabel('f (GHz)') plt.show()
Example #17
Source File: PostProcess.py From florence with MIT License | 5 votes |
def PlotNewtonRaphsonConvergence(self, increment=None, figure=None, show_plot=True, save=False, filename=None): """Plots convergence of Newton-Raphson for a given increment""" if self.fem_solver is None: raise ValueError("FEM solver not set for post-processing") if increment == None: increment = len(self.fem_solver.NRConvergence)-1 import matplotlib.pyplot as plt if figure is None: figure = plt.figure() plt.plot(np.log10(self.fem_solver.NRConvergence['Increment_'+str(increment)]),'-ko') axis_font = {'size':'18'} plt.xlabel(r'$No\;\; of\;\; Iterations$', **axis_font) plt.ylabel(r'$log_{10}|Residual|$', **axis_font) plt.grid('on') if save: if filename is None: warn("No filename provided. I am going to write one in the current directory") filename = PWD(__file__) + '/output.eps' plt.savefig(filename, format='eps', dpi=500) if show_plot: plt.show()
Example #18
Source File: utils.py From tf-3d-object-detection with MIT License | 5 votes |
def viz_single(pc): import mayavi.mlab as mlab fig = mlab.figure(figure=None, bgcolor=(0.4, 0.4, 0.4), fgcolor=None, engine=None, size=(500, 500)) mlab.points3d(pc[:, 0], pc[:, 1], pc[:, 2], mode='sphere', colormap='gnuplot', scale_factor=0.1, figure=fig) ''' Green points are original PC from KITTI White points are PC feed into the network Red point is the predicted center Yellow point the post-processed predicted bounding box corners ''' raw_input("Press any key to continue")
Example #19
Source File: draw_util.py From frustum-convnet with MIT License | 5 votes |
def show_lidar_with_boxes(pc_velo, objects, calib, img_fov=False, img_width=None, img_height=None): ''' Show all LiDAR points. Draw 3d box in LiDAR point cloud (in velo coord system) ''' if 'mlab' not in sys.modules: import mayavi.mlab as mlab from viz_util import draw_lidar_simple, draw_lidar, draw_gt_boxes3d print('All point num: ', pc_velo.shape[0]) fig = mlab.figure(figure=None, bgcolor=(0, 0, 0), fgcolor=None, engine=None, size=(1000, 500)) if img_fov: pc_velo = get_lidar_in_image_fov(pc_velo, calib, 0, 0, img_width, img_height) print('FOV point num: ', pc_velo.shape[0]) draw_lidar(pc_velo, fig=fig) for obj in objects: if obj.type == 'DontCare': continue # Draw 3d bounding box box3d_pts_2d, box3d_pts_3d = utils.compute_box_3d(obj, calib.P) box3d_pts_3d_velo = calib.project_rect_to_velo(box3d_pts_3d) # Draw heading arrow ori3d_pts_2d, ori3d_pts_3d = utils.compute_orientation_3d(obj, calib.P) ori3d_pts_3d_velo = calib.project_rect_to_velo(ori3d_pts_3d) x1, y1, z1 = ori3d_pts_3d_velo[0, :] x2, y2, z2 = ori3d_pts_3d_velo[1, :] draw_gt_boxes3d([box3d_pts_3d_velo], fig=fig) mlab.plot3d([x1, x2], [y1, y2], [z1, z2], color=(0.5, 0.5, 0.5), tube_radius=None, line_width=1, figure=fig) mlab.show(1)
Example #20
Source File: viz_util.py From frustum-pointnets with Apache License 2.0 | 5 votes |
def draw_gt_boxes3d(gt_boxes3d, fig, color=(1,1,1), line_width=1, draw_text=True, text_scale=(1,1,1), color_list=None): ''' Draw 3D bounding boxes Args: gt_boxes3d: numpy array (n,8,3) for XYZs of the box corners fig: mayavi figure handler color: RGB value tuple in range (0,1), box line color line_width: box line width draw_text: boolean, if true, write box indices beside boxes text_scale: three number tuple color_list: a list of RGB tuple, if not None, overwrite color. Returns: fig: updated fig ''' num = len(gt_boxes3d) for n in range(num): b = gt_boxes3d[n] if color_list is not None: color = color_list[n] if draw_text: mlab.text3d(b[4,0], b[4,1], b[4,2], '%d'%n, scale=text_scale, color=color, figure=fig) for k in range(0,4): #http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html i,j=k,(k+1)%4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) i,j=k+4,(k+1)%4 + 4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) i,j=k,k+4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) #mlab.show(1) #mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=62.0, figure=fig) return fig
Example #21
Source File: kitti_object.py From frustum-pointnets with Apache License 2.0 | 5 votes |
def show_lidar_with_boxes(pc_velo, objects, calib, img_fov=False, img_width=None, img_height=None): ''' Show all LiDAR points. Draw 3d box in LiDAR point cloud (in velo coord system) ''' if 'mlab' not in sys.modules: import mayavi.mlab as mlab from viz_util import draw_lidar_simple, draw_lidar, draw_gt_boxes3d print(('All point num: ', pc_velo.shape[0])) fig = mlab.figure(figure=None, bgcolor=(0,0,0), fgcolor=None, engine=None, size=(1000, 500)) if img_fov: pc_velo = get_lidar_in_image_fov(pc_velo, calib, 0, 0, img_width, img_height) print(('FOV point num: ', pc_velo.shape[0])) draw_lidar(pc_velo, fig=fig) for obj in objects: if obj.type=='DontCare':continue # Draw 3d bounding box box3d_pts_2d, box3d_pts_3d = utils.compute_box_3d(obj, calib.P) box3d_pts_3d_velo = calib.project_rect_to_velo(box3d_pts_3d) # Draw heading arrow ori3d_pts_2d, ori3d_pts_3d = utils.compute_orientation_3d(obj, calib.P) ori3d_pts_3d_velo = calib.project_rect_to_velo(ori3d_pts_3d) x1,y1,z1 = ori3d_pts_3d_velo[0,:] x2,y2,z2 = ori3d_pts_3d_velo[1,:] draw_gt_boxes3d([box3d_pts_3d_velo], fig=fig) mlab.plot3d([x1, x2], [y1, y2], [z1,z2], color=(0.5,0.5,0.5), tube_radius=None, line_width=1, figure=fig) mlab.show(1)
Example #22
Source File: 3d_elev_animations.py From LSDMappingTools with MIT License | 5 votes |
def run_plots(DataDirectory,Base_file): root = DataDirectory+Base_file filenames = get_filenames(root) counter = 0 # create the plot for the initial raster initial_file = filenames[0] # read in the raster raster = IO.ReadRasterArrayBlocks(initial_file) f = mlab.figure(size=(1000,1000), bgcolor=(0.5,0.5,0.5)) s = mlab.surf(raster, warp_scale=0.4, colormap='gist_earth', vmax=100) #mlab.outline(color=(0,0,0)) #mlab.axes(s, color=(1,1,1), z_axis_visibility=True, y_axis_visibility=False, xlabel='', ylabel='', zlabel='', ranges=[0,500,0,1000,0,0]) #@mlab.animate(delay=10) #def anim(): # now loop through each file and update the z values for fname in filenames: this_rast = IO.ReadRasterArrayBlocks(fname) s.mlab_source.scalars = this_rast #f.scene.render() # mlab.savefig(fname[:-4]+'_3d.png') #mlab.clf() # for (x, y, z) in zip(xs, ys, zs): # print('Updating scene...') # plt.mlab_source.set(x=x, y=y, z=z) # yield
Example #23
Source File: show_pcd.py From PointNetGPD with MIT License | 5 votes |
def show_obj(surface_points_, title, color='b'): mlab.figure(bgcolor=(0, 0, 0), fgcolor=(0.7, 0.7, 0.7), size=(1000, 1000)) if color == 'b': color_f = (0, 0, 1) elif color == 'r': color_f = (1, 0, 0) elif color == 'g': color_f = (0, 1, 0) else: color_f = (1, 1, 1) points_ = surface_points_ mlab.points3d(points_[:, 0], points_[:, 1], points_[:, 2], color=color_f, scale_factor=.0007) mlab.title(title, size=0.5)
Example #24
Source File: kitti_object.py From Geo-CNN with Apache License 2.0 | 5 votes |
def show_lidar_with_boxes(pc_velo, objects, calib, img_fov=False, img_width=None, img_height=None): ''' Show all LiDAR points. Draw 3d box in LiDAR point cloud (in velo coord system) ''' if 'mlab' not in sys.modules: import mayavi.mlab as mlab from viz_util import draw_lidar_simple, draw_lidar, draw_gt_boxes3d print(('All point num: ', pc_velo.shape[0])) fig = mlab.figure(figure=None, bgcolor=(0,0,0), fgcolor=None, engine=None, size=(1000, 500)) if img_fov: pc_velo = get_lidar_in_image_fov(pc_velo, calib, 0, 0, img_width, img_height) print(('FOV point num: ', pc_velo.shape[0])) draw_lidar(pc_velo, fig=fig) for obj in objects: if obj.type=='DontCare':continue # Draw 3d bounding box box3d_pts_2d, box3d_pts_3d = utils.compute_box_3d(obj, calib.P) box3d_pts_3d_velo = calib.project_rect_to_velo(box3d_pts_3d) # Draw heading arrow ori3d_pts_2d, ori3d_pts_3d = utils.compute_orientation_3d(obj, calib.P) ori3d_pts_3d_velo = calib.project_rect_to_velo(ori3d_pts_3d) x1,y1,z1 = ori3d_pts_3d_velo[0,:] x2,y2,z2 = ori3d_pts_3d_velo[1,:] draw_gt_boxes3d([box3d_pts_3d_velo], fig=fig) mlab.plot3d([x1, x2], [y1, y2], [z1,z2], color=(0.5,0.5,0.5), tube_radius=None, line_width=1, figure=fig) mlab.show(1)
Example #25
Source File: viz_util.py From Geo-CNN with Apache License 2.0 | 5 votes |
def draw_gt_boxes3d(gt_boxes3d, fig, color=(1,1,1), line_width=1, draw_text=True, text_scale=(1,1,1), color_list=None): ''' Draw 3D bounding boxes Args: gt_boxes3d: numpy array (n,8,3) for XYZs of the box corners fig: mayavi figure handler color: RGB value tuple in range (0,1), box line color line_width: box line width draw_text: boolean, if true, write box indices beside boxes text_scale: three number tuple color_list: a list of RGB tuple, if not None, overwrite color. Returns: fig: updated fig ''' num = len(gt_boxes3d) for n in range(num): b = gt_boxes3d[n] if color_list is not None: color = color_list[n] if draw_text: mlab.text3d(b[4,0], b[4,1], b[4,2], '%d'%n, scale=text_scale, color=color, figure=fig) for k in range(0,4): #http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html i,j=k,(k+1)%4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) i,j=k+4,(k+1)%4 + 4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) i,j=k,k+4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) #mlab.show(1) #mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=62.0, figure=fig) return fig
Example #26
Source File: utils.py From cvml_project with MIT License | 5 votes |
def draw_lidar(pc, color=None, fig=None, bgcolor=(0, 0, 0), pts_scale=1, pts_mode='point', pts_color=None): """ Add lidar points Args: pc: point cloud xyz [npoints, 3] color: fig: fig handler Returns: """ ''' 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] # add points 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) return fig
Example #27
Source File: S2.py From lie_learn with MIT License | 5 votes |
def plot_sphere_func(f, grid='Clenshaw-Curtis', beta=None, alpha=None, colormap='jet', fignum=0, normalize=True): #TODO: All grids except Clenshaw-Curtis have holes at the poles # TODO: update this function now that we changed the order of axes in f import matplotlib matplotlib.use('WxAgg') matplotlib.interactive(True) from mayavi import mlab if normalize: f = (f - np.min(f)) / (np.max(f) - np.min(f)) if grid == 'Driscoll-Healy': b = f.shape[0] / 2 elif grid == 'Clenshaw-Curtis': b = (f.shape[0] - 2) / 2 elif grid == 'SOFT': b = f.shape[0] / 2 elif grid == 'Gauss-Legendre': b = (f.shape[0] - 2) / 2 if beta is None or alpha is None: beta, alpha = meshgrid(b=b, grid_type=grid) alpha = np.r_[alpha, alpha[0, :][None, :]] beta = np.r_[beta, beta[0, :][None, :]] f = np.r_[f, f[0, :][None, :]] x = np.sin(beta) * np.cos(alpha) y = np.sin(beta) * np.sin(alpha) z = np.cos(beta) mlab.figure(fignum, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0), size=(600, 400)) mlab.clf() mlab.mesh(x, y, z, scalars=f, colormap=colormap) #mlab.view(90, 70, 6.2, (-1.3, -2.9, 0.25)) mlab.show()
Example #28
Source File: mayavi_viewer.py From Complex-YOLOv3 with GNU General Public License v3.0 | 5 votes |
def show_lidar_with_boxes(pc_velo, objects, calib, img_fov=False, img_width=None, img_height=None, fig=None): ''' Show all LiDAR points. Draw 3d box in LiDAR point cloud (in velo coord system) ''' if not fig: fig = mlab.figure(figure="KITTI_POINT_CLOUD", bgcolor=(0,0,0), fgcolor=None, engine=None, size=(1250, 550)) if img_fov: pc_velo = get_lidar_in_image_fov(pc_velo, calib, 0, 0, img_width, img_height) draw_lidar(pc_velo, fig1=fig) for obj in objects: if obj.type=='DontCare':continue # Draw 3d bounding box box3d_pts_2d, box3d_pts_3d = kitti_utils.compute_box_3d(obj, calib.P) box3d_pts_3d_velo = calib.project_rect_to_velo(box3d_pts_3d) # Draw heading arrow ori3d_pts_2d, ori3d_pts_3d = kitti_utils.compute_orientation_3d(obj, calib.P) ori3d_pts_3d_velo = calib.project_rect_to_velo(ori3d_pts_3d) x1,y1,z1 = ori3d_pts_3d_velo[0,:] x2,y2,z2 = ori3d_pts_3d_velo[1,:] draw_gt_boxes3d([box3d_pts_3d_velo], fig=fig, color=(0,1,1), line_width=2, draw_text=False) mlab.plot3d([x1, x2], [y1, y2], [z1,z2], color=(0.5,0.5,0.5), tube_radius=None, line_width=1, figure=fig) mlab.view(distance=90)
Example #29
Source File: mayavi_viewer.py From Complex-YOLOv3 with GNU General Public License v3.0 | 5 votes |
def draw_gt_boxes3d(gt_boxes3d, fig, color=(1,1,1), line_width=2, draw_text=True, text_scale=(1,1,1), color_list=None): ''' Draw 3D bounding boxes Args: gt_boxes3d: numpy array (n,8,3) for XYZs of the box corners fig: mayavi figure handler color: RGB value tuple in range (0,1), box line color line_width: box line width draw_text: boolean, if true, write box indices beside boxes text_scale: three number tuple color_list: a list of RGB tuple, if not None, overwrite color. Returns: fig: updated fig ''' num = len(gt_boxes3d) for n in range(num): b = gt_boxes3d[n] if color_list is not None: color = color_list[n] if draw_text: mlab.text3d(b[4,0], b[4,1], b[4,2], '%d'%n, scale=text_scale, color=color, figure=fig) for k in range(0,4): #http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html i,j=k,(k+1)%4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) i,j=k+4,(k+1)%4 + 4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) i,j=k,k+4 mlab.plot3d([b[i,0], b[j,0]], [b[i,1], b[j,1]], [b[i,2], b[j,2]], color=color, tube_radius=None, line_width=line_width, figure=fig) #mlab.show(1) #mlab.view(azimuth=180, elevation=70, focalpoint=[ 12.0909996 , -1.04700089, -2.03249991], distance=62.0, figure=fig) return fig
Example #30
Source File: tracker_tools.py From argoverse_baselinetracker with MIT License | 5 votes |
def show_pc_segments(pc_all, pc_all2, pc_segments): """ 3D visualization of segmentation result """ from mayavi import mlab mlab.figure(bgcolor=(0.0,0.0,0.0)) mlab.points3d(pc_all[:,0],pc_all[:,1],pc_all[:,2],scale_factor=0.1,color=(0.3,0.2,0.2),opacity=0.3) mlab.points3d(pc_all2[:,0],pc_all2[:,1],pc_all2[:,2],scale_factor=0.1,color=(0.4,0.4,0.4),opacity=1.0) for i in range(len(pc_segments)): color = (random.random()*0.8 + 0.2 ,random.random()*0.8 + 0.2 ,random.random()*0.8 + 0.2) nodes1 = mlab.points3d(pc_segments[i][:,0],pc_segments[i][:,1],pc_segments[i][:,2],scale_factor=0.1,color=color,opacity=0.8) nodes1.glyph.scale_mode = 'scale_by_vector' length_axis = 2.0 linewidth_axis = 0.1 color_axis = (1.0,0.0,0.0) pc_axis = np.array([[0,0,0], [length_axis,0,0], [0,length_axis,0],[0,0,length_axis]]) mlab.plot3d(pc_axis[0:2,0], pc_axis[0:2,1], pc_axis[0:2,2],tube_radius=linewidth_axis, color=(1.0,0.0,0.0)) mlab.plot3d(pc_axis[[0,2],0], pc_axis[[0,2],1], pc_axis[[0,2],2],tube_radius=linewidth_axis, color=(0.0,1.0,0.0)) mlab.plot3d(pc_axis[[0,3],0], pc_axis[[0,3],1], pc_axis[[0,3],2],tube_radius=linewidth_axis, color=(0.0,0.0,1.0)) mlab.show()