当前位置: 首页>>代码示例>>Python>>正文


Python mlab.show方法代码示例

本文整理汇总了Python中mayavi.mlab.show方法的典型用法代码示例。如果您正苦于以下问题:Python mlab.show方法的具体用法?Python mlab.show怎么用?Python mlab.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mayavi.mlab的用法示例。


在下文中一共展示了mlab.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: surface_3d

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def surface_3d():
    """
    使用Mayavi将二维数组绘制成3D曲面 x * exp(x**2 - y**2)
    :return:
    """
    import numpy as np
    # create data
    x, y = np.ogrid[-2:2:20j, -2:2:20j]
    z = x * np.exp(- x ** 2 - y ** 2)

    # view it
    from mayavi import mlab

    # 绘制一个三维空间中的曲面
    pl = mlab.surf(x, y, z, warp_scale="auto")

    # 在三维空间中添加坐标轴
    mlab.axes(xlabel='x', ylabel='y', zlabel='z')

    # 在三维空间中添加曲面区域的外框
    mlab.outline(pl)

    mlab.show() 
开发者ID:tomoncle,项目名称:Python-notes,代码行数:25,代码来源:mlab_3d.py

示例2: surface_spherical_harmonic

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def surface_spherical_harmonic():
    # Create the data.
    from numpy import pi, sin, cos, mgrid
    dphi, dtheta = pi / 250.0, pi / 250.0
    [phi, theta] = mgrid[0:pi + dphi * 1.5:dphi, 0:2 * pi + dtheta * 1.5:dtheta]
    m0 = 4
    m1 = 3
    m2 = 2
    m3 = 3
    m4 = 6
    m5 = 2
    m6 = 6
    m7 = 4
    r = sin(m0 * phi) ** m1 + cos(m2 * phi) ** m3 + sin(m4 * theta) ** m5 + cos(m6 * theta) ** m7
    x = r * sin(phi) * cos(theta)
    y = r * cos(phi)
    z = r * sin(phi) * sin(theta)

    # View it.
    from mayavi import mlab
    mlab.mesh(x, y, z)
    mlab.show() 
开发者ID:tomoncle,项目名称:Python-notes,代码行数:24,代码来源:mlab_3d.py

示例3: test_plot3d

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def test_plot3d():
    import numpy
    from mayavi import mlab

    """Generates a pretty set of lines."""
    n_mer, n_long = 6, 11
    pi = numpy.pi
    dphi = pi / 1000.0
    phi = numpy.arange(0.0, 2 * pi + 0.5 * dphi, dphi)
    mu = phi * n_mer
    x = numpy.cos(mu) * (1 + numpy.cos(n_long * mu / n_mer) * 0.5)
    y = numpy.sin(mu) * (1 + numpy.cos(n_long * mu / n_mer) * 0.5)
    z = numpy.sin(n_long * mu / n_mer) * 0.5

    l = mlab.plot3d(x, y, z, numpy.sin(mu), tube_radius=0.025, colormap='Spectral')
    mlab.show() 
开发者ID:tomoncle,项目名称:Python-notes,代码行数:18,代码来源:mlab_3d.py

示例4: viz_kitti_video

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def viz_kitti_video():
    video_path = os.path.join(ROOT_DIR, 'dataset/2011_09_26/')
    dataset = kitti_object_video(\
        os.path.join(video_path, '2011_09_26_drive_0023_sync/image_02/data'),
        os.path.join(video_path, '2011_09_26_drive_0023_sync/velodyne_points/data'),
        video_path)
    print(len(dataset))
    for i in range(len(dataset)):
        img = dataset.get_image(0)
        pc = dataset.get_lidar(0)
        Image.fromarray(img).show()
        draw_lidar(pc)
        raw_input()
        pc[:,0:3] = dataset.get_calibration().project_velo_to_rect(pc[:,0:3])
        draw_lidar(pc)
        raw_input()
    return 
开发者ID:voidrank,项目名称:Geo-CNN,代码行数:19,代码来源:kitti_object.py

示例5: show_lidar_on_image

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def show_lidar_on_image(pc_velo, img, calib, img_width, img_height):
    ''' Project LiDAR points to image '''
    imgfov_pc_velo, pts_2d, fov_inds = get_lidar_in_image_fov(pc_velo,
        calib, 0, 0, img_width, img_height, True)
    imgfov_pts_2d = pts_2d[fov_inds,:]
    imgfov_pc_rect = calib.project_velo_to_rect(imgfov_pc_velo)

    import matplotlib.pyplot as plt
    cmap = plt.cm.get_cmap('hsv', 256)
    cmap = np.array([cmap(i) for i in range(256)])[:,:3]*255

    for i in range(imgfov_pts_2d.shape[0]):
        depth = imgfov_pc_rect[i,2]
        color = cmap[int(640.0/depth),:]
        cv2.circle(img, (int(np.round(imgfov_pts_2d[i,0])),
            int(np.round(imgfov_pts_2d[i,1]))),
            2, color=tuple(color), thickness=-1)
    Image.fromarray(img).show() 
    return img 
开发者ID:voidrank,项目名称:Geo-CNN,代码行数:21,代码来源:kitti_object.py

示例6: display_gripper_on_object

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
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() 
开发者ID:lianghongzhuo,项目名称:PointNetGPD,代码行数:21,代码来源:read_grasps_from_file.py

示例7: remove_white_pixel

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def remove_white_pixel(msg, points_, vis=False):
    points_with_c_ = pointclouds.pointcloud2_to_array(msg)
    points_with_c_ = pointclouds.split_rgb_field(points_with_c_)
    r = np.asarray(points_with_c_['r'], dtype=np.uint32)
    g = np.asarray(points_with_c_['g'], dtype=np.uint32)
    b = np.asarray(points_with_c_['b'], dtype=np.uint32)
    rgb_colors = np.vstack([r, g, b]).T
    # rgb = rgb_colors.astype(np.float) / 255
    ind_good_points_ = np.sum(rgb_colors[:] < 210, axis=-1) == 3
    ind_good_points_ = np.where(ind_good_points_ == 1)[0]
    new_points_ = points_[ind_good_points_]
    if vis:
        p = points_
        mlab.points3d(p[:, 0], p[:, 1], p[:, 2], scale_factor=0.002, color=(1, 0, 0))
        p = new_points_
        mlab.points3d(p[:, 0], p[:, 1], p[:, 2], scale_factor=0.002, color=(0, 0, 1))
        mlab.points3d(0, 0, 0, scale_factor=0.01, color=(0, 1, 0))  # plot 0 point
        mlab.show()
    return new_points_ 
开发者ID:lianghongzhuo,项目名称:PointNetGPD,代码行数:21,代码来源:kinect2grasp_python2.py

示例8: main

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def main():
    mu = np.array([1, 10, 20])
    sigma = np.matrix([[20, 10, 10],
                       [10, 25, 1],
                       [10, 1, 50]])
    np.random.seed(100)
    data = np.random.multivariate_normal(mu, sigma, 1000)
    values = data.T

    kde = stats.gaussian_kde(values)

    # Create a regular 3D grid with 50 points in each dimension
    xmin, ymin, zmin = data.min(axis=0)
    xmax, ymax, zmax = data.max(axis=0)
    xi, yi, zi = np.mgrid[xmin:xmax:50j, ymin:ymax:50j, zmin:zmax:50j]

    # Evaluate the KDE on a regular grid...
    coords = np.vstack([item.ravel() for item in [xi, yi, zi]])
    density = kde(coords).reshape(xi.shape)

    # Visualize the density estimate as isosurfaces
    mlab.contour3d(xi, yi, zi, density, opacity=0.5)
    mlab.axes()
    mlab.show() 
开发者ID:kklmn,项目名称:xrt,代码行数:26,代码来源:kde_mlab.py

示例9: viz_kitti_video

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def viz_kitti_video():
    video_path = os.path.join(ROOT_DIR, 'dataset\\2011_09_26\\')
    dataset = kitti_object_video(\
        os.path.join(video_path, '2011_09_26_drive_0023_sync\\image_02\\data'),
        os.path.join(video_path, '2011_09_26_drive_0023_sync\\velodyne_points\\data'),
        video_path)
    print(len(dataset))
    for i in range(len(dataset)):
        img = dataset.get_image(0)
        pc = dataset.get_lidar(0)
        Image.fromarray(img).show()
        draw_lidar(pc)
        raw_input()
        pc[:,0:3] = dataset.get_calibration().project_velo_to_rect(pc[:,0:3])
        draw_lidar(pc)
        raw_input()
    return 
开发者ID:chonepieceyb,项目名称:reading-frustum-pointnets-code,代码行数:19,代码来源:view_results.py

示例10: show

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def show(plane, expected_n_contours):
        P = meshcut.cross_section_mesh(mesh, plane)
        colors = [
            (0, 1, 1),
            (1, 0, 1),
            (0, 0, 1)
        ]
        print("num contours : ", len(P), ' expected : ', expected_n_contours)

        if True:
            utils.trimesh3d(mesh.verts, mesh.tris, color=(1, 1, 1),
                            opacity=0.5)
            utils.show_plane(plane.orig, plane.n, scale=1, color=(1, 0, 0),
                             opacity=0.5)

            for p, color in zip(P, itertools.cycle(colors)):
                p = np.array(p)
                mlab.plot3d(p[:, 0], p[:, 1], p[:, 2], tube_radius=None,
                            line_width=3.0, color=color)
        return P

    ##
    # This will align the plane with some edges, so this is a good test
    # for vertices intersection handling 
开发者ID:julienr,项目名称:meshcut,代码行数:26,代码来源:0_cross_section.py

示例11: show

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def show(plane):
        P = meshcut.cross_section_mesh(mesh, plane)
        colors = [
            (0, 1, 1),
            (1, 0, 1),
            (0, 0, 1)
        ]
        print("num contours : ", len(P))

        if True:
            utils.trimesh3d(mesh.verts, mesh.tris, color=(1, 1, 1),
                            opacity=0.5, representation='wireframe')
            utils.show_plane(plane.orig, plane.n, scale=1, color=(1, 0, 0),
                             opacity=0.5)

            for p, color in zip(P, itertools.cycle(colors)):
                p = np.array(p)
                mlab.plot3d(p[:, 0], p[:, 1], p[:, 2], tube_radius=None,
                            line_width=3.0, color=color)
        return P

    ## 
开发者ID:julienr,项目名称:meshcut,代码行数:24,代码来源:1_stl_sphere_cut.py

示例12: render_body

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [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() 
开发者ID:aschampion,项目名称:diluvian,代码行数:24,代码来源:regions.py

示例13: show_lidar_on_image

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def show_lidar_on_image(pc_velo, img, calib, img_width, img_height):
    ''' Project LiDAR points to image '''
    imgfov_pc_velo, pts_2d, fov_inds = get_lidar_in_image_fov(pc_velo,
                                                              calib, 0, 0, img_width, img_height, True)
    imgfov_pts_2d = pts_2d[fov_inds, :]
    imgfov_pc_rect = calib.project_velo_to_rect(imgfov_pc_velo)

    import matplotlib.pyplot as plt
    cmap = plt.cm.get_cmap('hsv', 256)
    cmap = np.array([cmap(i) for i in range(256)])[:, :3] * 255

    for i in range(imgfov_pts_2d.shape[0]):
        depth = imgfov_pc_rect[i, 2]
        color = cmap[int(640.0 / depth), :]
        cv2.circle(img, (int(np.round(imgfov_pts_2d[i, 0])),
                         int(np.round(imgfov_pts_2d[i, 1]))),
                   2, color=tuple(color), thickness=-1)
    Image.fromarray(img).show()
    return img 
开发者ID:zhixinwang,项目名称:frustum-convnet,代码行数:21,代码来源:draw_util.py

示例14: viz_kitti_video

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def viz_kitti_video():
    video_path = os.path.join(ROOT_DIR, 'dataset/2011_09_26/')
    dataset = kitti_object_video(
        os.path.join(video_path, '2011_09_26_drive_0023_sync/image_02/data'),
        os.path.join(video_path, '2011_09_26_drive_0023_sync/velodyne_points/data'),
        video_path)
    print(len(dataset))
    for i in range(len(dataset)):
        img = dataset.get_image(0)
        pc = dataset.get_lidar(0)
        Image.fromarray(img).show()
        draw_lidar(pc)
        input()
        pc[:, 0:3] = dataset.get_calibration().project_velo_to_rect(pc[:, 0:3])
        draw_lidar(pc)
        input()
    return 
开发者ID:zhixinwang,项目名称:frustum-convnet,代码行数:19,代码来源:draw_util.py

示例15: plot_mcontour

# 需要导入模块: from mayavi import mlab [as 别名]
# 或者: from mayavi.mlab import show [as 别名]
def plot_mcontour(self, ndim0, ndim1, z, show_mode):
        "use mayavi.mlab to plot contour."
        if not mayavi_installed:
            self.__logger.info("Mayavi is not installed on your device.")
            return
        #do 2d interpolation
        #get slice object
        s = np.s_[0:ndim0:1, 0:ndim1:1]
        x, y = np.ogrid[s]
        mx, my = np.mgrid[s]
        #use cubic 2d interpolation
        interpfunc = interp2d(x, y, z, kind='cubic')
        newx = np.linspace(0, ndim0, 600)
        newy = np.linspace(0, ndim1, 600)
        newz = interpfunc(newx, newy)
        #mlab
        face = mlab.surf(newx, newy, newz, warp_scale=2)
        mlab.axes(xlabel='x', ylabel='y', zlabel='z')
        mlab.outline(face)
        #save or show
        if show_mode == 'show':
            mlab.show()
        elif show_mode == 'save':
            mlab.savefig('mlab_contour3d.png')
        else:
            raise ValueError('Unrecognized show mode parameter : ' +
                             show_mode)

        return 
开发者ID:PytLab,项目名称:VASPy,代码行数:31,代码来源:electro.py


注:本文中的mayavi.mlab.show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。