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


Python open3d.draw_geometries方法代码示例

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


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

示例1: vis_pc

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def vis_pc(xyz, color_axis=-1, rgb=None):
    # TODO move to the other module and do import in the module
    import open3d
    pcd = open3d.PointCloud()
    pcd.points = open3d.Vector3dVector(xyz)

    if color_axis >= 0:
        if color_axis == 3:
            axis_vis = np.arange(0, xyz.shape[0], dtype=np.float32)
        else:
            axis_vis = xyz[:, color_axis]
        min_ = np.min(axis_vis)
        max_ = np.max(axis_vis)

        colors = cm.gist_rainbow((axis_vis - min_) / (max_ - min_))[:, 0:3]
        pcd.colors = open3d.Vector3dVector(colors)
    if rgb is not None:
        pcd.colors = open3d.Vector3dVector(rgb)

    open3d.draw_geometries([pcd]) 
开发者ID:eldar,项目名称:differentiable-point-clouds,代码行数:22,代码来源:visualise.py

示例2: getPcRGBD

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def getPcRGBD(path, idx):

    frame = 'frame-000000'
    frame = frame[:-len(idx)] + idx
    depth = frame + '.depth.png'
    depth = os.path.join(path, depth)
    rgb = frame + '.color.png'
    rgb = os.path.join(path, rgb)


    im_depth = o3d.read_image(depth)
    im_color = o3d.read_image(rgb)

    # rgbd_image = o3d.create_rgbd_image_from_color_and_depth(im_color, im_depth)

    pcd = o3d.create_point_cloud_from_depth_image(im_depth, o3d.PinholeCameraIntrinsic(
    # pcd = o3d.create_point_cloud_from_rgbd_image(rgbd_image, o3d.PinholeCameraIntrinsic(
        o3d.PinholeCameraIntrinsicParameters.PrimeSenseDefault))

    # o3d.draw_geometries([pcd])

    return pcd 
开发者ID:goncalo120,项目名称:3DRegNet,代码行数:24,代码来源:setupPly.py

示例3: draw_registration_result

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def draw_registration_result(source, target, transformation):
    source_temp = copy.deepcopy(source)
    target_temp = copy.deepcopy(target)
    source = copy.deepcopy(source)
    source_temp.paint_uniform_color([1, 0.706, 0])
    target_temp.paint_uniform_color([0, 0.651, 0.929])
    source.paint_uniform_color([1, 0, 0])
    source_temp.transform(transformation)

    vis = o3d.VisualizerWithEditing()
    vis.create_window()
    vis.add_geometry(source_temp)
    pos = os.path.join(os.getcwd(), 'registration', 'pos.json')
    vis.get_render_option().load_from_json(pos)
    vis.run()  # user picks points
    vis.destroy_window()

    # o3d.draw_geometries([source_temp, target_temp]) 
开发者ID:goncalo120,项目名称:3DRegNet,代码行数:20,代码来源:setupPly.py

示例4: draw_registration_result

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def draw_registration_result(src, trgt):
    source = open3d.PointCloud()
    source.points = open3d.Vector3dVector(src)
    target = open3d.PointCloud()
    target.points = open3d.Vector3dVector(trgt)
    source.paint_uniform_color([1, 0.706, 0])
    target.paint_uniform_color([0, 0.651, 0.929])
    open3d.draw_geometries([source, target]) 
开发者ID:eldar,项目名称:differentiable-point-clouds,代码行数:10,代码来源:compute_alignment.py

示例5: view_snapshot

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def view_snapshot(sessionname):
    cloud, trajectory = load_snapshot(sessionname)
    o3.draw_geometries([cloud, trajectory]) 
开发者ID:acschaefer,项目名称:polex,代码行数:5,代码来源:pynclt.py

示例6: view_local_maps

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def view_local_maps(sessionname):
    sessiondir = os.path.join('nclt', sessionname)
    session = pynclt.session(sessionname)
    maps = np.load(os.path.join(sessiondir, get_localmapfile()))['maps']
    for i, map in enumerate(maps):
        print('Map #{}'.format(i))
        mapboundsvis = util.create_wire_box(mapextent, [0.0, 0.0, 1.0])
        mapboundsvis.transform(map['T_w_m'])
        polevis = []
        for poleparams in map['poleparams']:
            x, y, zs, ze, a = poleparams[:5]
            pole = util.create_wire_box(
                [a, a, ze - zs], color=[1.0, 1.0, 0.0])
            T_m_p = np.identity(4)
            T_m_p[:3, 3] = [x - 0.5 * a, y - 0.5 * a, zs]
            pole.transform(map['T_w_m'].dot(T_m_p))
            polevis.append(pole)

        accucloud = o3.PointCloud()
        for j in range(map['istart'], map['iend']):
            points, intensities = session.get_velo(j)
            cloud = o3.PointCloud()
            cloud.points = o3.Vector3dVector(points)
            cloud.colors = o3.Vector3dVector(
                util.intensity2color(intensities / 255.0))
            cloud.transform(session.T_w_r_odo_velo[j])
            accucloud.points.extend(cloud.points)
            accucloud.colors.extend(cloud.colors)

        o3.draw_geometries([accucloud, mapboundsvis] + polevis) 
开发者ID:acschaefer,项目名称:polex,代码行数:32,代码来源:ncltpoles.py

示例7: save_local_maps

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def save_local_maps(seq):
    print(seq)
    sequence = dataset.sequence(seq)
    seqdir = os.path.join('kitti', '{:03d}'.format(seq))
    util.makedirs(seqdir)
    istart, imid, iend = get_map_indices(sequence)
    maps = []
    with progressbar.ProgressBar(max_value=len(iend)) as bar:
        for i in range(len(iend)):
            scans = []
            for idx, val in enumerate(range(istart[i], iend[i])):
                velo = sequence.get_velo(val)
                scan = o3.PointCloud()
                scan.points = o3.Vector3dVector(velo[:, :3])
                scan.colors = o3.Vector3dVector(
                    util.intensity2color(velo[:, 3]))
                scans.append(scan)

            T_m_w = T_m_mc.dot(T_mc_cam0).dot(
                util.invert_ht(sequence.poses[imid[i]]))
            T_w_velo = np.matmul(
                sequence.poses[istart[i]:iend[i]], sequence.calib.T_cam0_velo)
            T_m_velo = np.matmul(T_m_w, T_w_velo)
            occupancymap = mapping.occupancymap(
                scans, T_m_velo, mapshape, mapsize)
            poleparams = poles.detect_poles(occupancymap, mapsize)

            # accuscan = o3.PointCloud()
            # for j in range(len(scans)):
            #     scans[j].transform(T_w_velo[j])
            #     accuscan.points.extend(scans[j].points)
            # o3.draw_geometries([accuscan])

            # import ndshow
            # ndshow.matshow(occupancymap.transpose([2, 0, 1]))

            map = {'poleparams': poleparams, 
                'istart': istart[i], 'imid': imid[i], 'iend': iend[i]}
            maps.append(map)
            bar.update(i)
    np.savez(os.path.join(seqdir, localmapfile), maps=maps) 
开发者ID:acschaefer,项目名称:polex,代码行数:43,代码来源:kittipoles.py

示例8: view_local_maps

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def view_local_maps(seq):
    sequence = dataset.sequence(seq)
    seqdir = os.path.join('kitti', '{:03d}'.format(seq))
    with np.load(os.path.join(seqdir, localmapfile)) as data:
        for i, map in enumerate(data['maps']):
            T_w_m = sequence.poses[map['imid']].dot(T_cam0_mc).dot(T_mc_m)
            mapboundsvis = util.create_wire_box(mapextent, [0.0, 0.0, 1.0])
            mapboundsvis.transform(T_w_m)
        
            polemap = []
            for poleparams in map['poleparams']:
                x, y, zs, ze, a, _ = poleparams
                pole = util.create_wire_box(
                    [a, a, ze - zs], color=[1.0, 1.0, 0.0])
                T_m_p = np.identity(4)
                T_m_p[:3, 3] = [x - 0.5 * a, y - 0.5 * a, zs]
                pole.transform(T_w_m.dot(T_m_p))
                polemap.append(pole)

            accucloud = o3.PointCloud()
            for j in range(map['istart'], map['iend']):
                velo = sequence.get_velo(j)
                cloud = o3.PointCloud()
                cloud.points = o3.Vector3dVector(velo[:, :3])
                cloud.colors = o3.Vector3dVector(
                    util.intensity2color(velo[:, 3]))
                cloud.transform(
                    sequence.poses[j].dot(sequence.calib.T_cam0_velo))
                accucloud.points.extend(cloud.points)
                accucloud.colors.extend(cloud.colors)
            o3.draw_geometries([accucloud, mapboundsvis] + polemap) 
开发者ID:acschaefer,项目名称:polex,代码行数:33,代码来源:kittipoles.py

示例9: draw_registration_result

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def draw_registration_result(source, target, transformation):
    source_temp = copy.deepcopy(source)
    target_temp = copy.deepcopy(target)
    open3d.estimate_normals(source_temp)
    open3d.estimate_normals(target_temp)
    source_temp.paint_uniform_color([1, 0.706, 0])
    target_temp.paint_uniform_color([0, 0.651, 0.929])
    source_temp.transform(transformation)
    open3d.draw_geometries([source_temp, target_temp]) 
开发者ID:XuyangBai,项目名称:D3Feat,代码行数:11,代码来源:demo_registration.py

示例10: vis_voxels

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def vis_voxels(cfg, voxels, rgb=None, vis_axis=0):
    # TODO move to the other module and do import in the module
    import open3d
    threshold = cfg.vis_threshold
    xyz, occupancies = voxel2pc(voxels, threshold)

    # Pass xyz to Open3D.PointCloud and visualize
    pcd = open3d.PointCloud()
    pcd.points = open3d.Vector3dVector(xyz)

    if rgb is not None:
        rgbs = np.reshape(rgb, (-1, 3))

        colors = rgbs[occupancies, :]
        colors = np.clip(colors, 0.0, 1.0)

        pcd.colors = open3d.Vector3dVector(colors)
    else:
        voxels = np.squeeze(voxels)
        sh = voxels.shape
        rgb = np.zeros((sh[0], sh[1], sh[2], 3), dtype=np.float32)
        for k in range(sh[0]):
            color = cm.gist_rainbow(float(k) / (sh[0] - 1))[:3]
            if vis_axis == 0:
                rgb[k, :, :, :] = color
            elif vis_axis == 1:
                rgb[:, k, :, :] = color
            elif vis_axis == 2:
                rgb[:, :, k, :] = color
            else:
                assert(False)

        rgbs = np.reshape(rgb, (-1, 3))
        colors = rgbs[occupancies, :]
        pcd.colors = open3d.Vector3dVector(colors)

    if False:
        axis_vis = xyz[:, 0]
        min_ = np.min(axis_vis)
        max_ = np.max(axis_vis)
        colors = cm.gist_rainbow((axis_vis - min_) / (max_ - min_))[:, 0:3]
        pcd.colors = open3d.Vector3dVector(colors)

    # open3d.write_point_cloud("sync.ply", pcd)

    # Load saved point cloud and transform it into NumPy array
    # pcd_load = open3d.read_point_cloud("sync.ply")
    # xyz_load = np.asarray(pcd_load.points)
    # print(xyz_load)

    # visualization
    open3d.draw_geometries([pcd]) 
开发者ID:eldar,项目名称:differentiable-point-clouds,代码行数:54,代码来源:visualise.py

示例11: main

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def main():
    home_dir = expanduser("~")
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--img_dir",
        help="path to the directory that saves" " depth and rgb images from ORB_SLAMA2",
        default="%s/.ros/Imgs" % home_dir,
        type=str,
    )
    parser.add_argument(
        "--depth_max", default=1.5, help="maximum value for the depth", type=float
    )
    parser.add_argument(
        "--depth_min", default=0.2, help="minimum value for the depth", type=float
    )
    parser.add_argument(
        "--cfg_filename",
        default="realsense_d435.yaml",
        help="which config file to use",
        type=str,
    )
    parser.add_argument(
        "--subsample_pixs",
        default=1,
        help="sample every n pixels in row/column"
        "when the point cloud is reconstructed",
        type=int,
    )
    args = parser.parse_args()
    rospy.init_node("reconstruct_world", anonymous=True)
    rgb_dir = os.path.join(args.img_dir, "RGBImgs")
    depth_dir = os.path.join(args.img_dir, "DepthImgs")
    pcd_processor = PointCloudProcessor(
        rgb_dir=rgb_dir,
        depth_dir=depth_dir,
        cfg_filename=args.cfg_filename,
        subsample_pixs=args.subsample_pixs,
        depth_threshold=(args.depth_min, args.depth_max),
    )
    time.sleep(2)
    points, colors = pcd_processor.get_current_pcd()
    if USE_OPEN3D:
        pcd = open3d.PointCloud()
        pcd.points = open3d.Vector3dVector(points)
        pcd.colors = open3d.Vector3dVector(colors / 255.0)
        coord = open3d.create_mesh_coordinate_frame(1, [0, 0, 0])
        open3d.draw_geometries([pcd, coord]) 
开发者ID:facebookresearch,项目名称:pyrobot,代码行数:49,代码来源:pcdlib.py

示例12: save_local_maps

# 需要导入模块: import open3d [as 别名]
# 或者: from open3d import draw_geometries [as 别名]
def save_local_maps(sessionname, visualize=False):
    print(sessionname)
    session = pynclt.session(sessionname)
    util.makedirs(session.dir)
    istart, imid, iend = get_map_indices(session)
    maps = []
    with progressbar.ProgressBar(max_value=len(iend)) as bar:
        for i in range(len(iend)):
            scans = []
            for idx, val in enumerate(range(istart[i], iend[i])):
                xyz, _ = session.get_velo(val)
                scan = o3.PointCloud()
                scan.points = o3.Vector3dVector(xyz)
                scans.append(scan)

            T_w_mc = util.project_xy(
                session.T_w_r_odo_velo[imid[i]].dot(T_r_mc))
            T_w_m = T_w_mc.dot(T_mc_m)
            T_m_w = util.invert_ht(T_w_m)
            T_w_r = session.T_w_r_odo_velo[istart[i]:iend[i]]
            T_m_r = np.matmul(T_m_w, T_w_r)

            occupancymap = mapping.occupancymap(scans, T_m_r, mapshape, mapsize)
            poleparams = poles.detect_poles(occupancymap, mapsize)

            if visualize:
                cloud = o3.PointCloud()
                for T, scan in zip(T_w_r, scans):
                    s = copy.copy(scan)
                    s.transform(T)
                    cloud.points.extend(s.points)
                mapboundsvis = util.create_wire_box(mapextent, [0.0, 0.0, 1.0])
                mapboundsvis.transform(T_w_m)
                polevis = []
                for j in range(poleparams.shape[0]):
                    x, y, zs, ze, a = poleparams[j, :5]
                    pole = util.create_wire_box(
                        [a, a, ze - zs], color=[1.0, 1.0, 0.0])
                    T_m_p = np.identity(4)
                    T_m_p[:3, 3] = [x - 0.5 * a, y - 0.5 * a, zs]
                    pole.transform(T_w_m.dot(T_m_p))
                    polevis.append(pole)
                o3.draw_geometries(polevis + [cloud, mapboundsvis])

            map = {'poleparams': poleparams, 'T_w_m': T_w_m,
                'istart': istart[i], 'imid': imid[i], 'iend': iend[i]}
            maps.append(map)
            bar.update(i)
    np.savez(os.path.join(session.dir, get_localmapfile()), maps=maps) 
开发者ID:acschaefer,项目名称:polex,代码行数:51,代码来源:ncltpoles.py


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