Exemplo n.º 1
0
def convert_pcl(data):
    import py3d
    header = '''# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z rgb
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH %d
HEIGHT %d
VIEWPOINT 0 0 0 1 0 0 0
POINTS %d
DATA ascii'''

    with open(tmp_pcd_name, 'w') as f:
        f.write(header % (data.width, data.height, data.width * data.height))
        f.write("\n")

        for p in pc2.read_points(data, skip_nans=True):
            f.write('%f %f %f %e' % (p[0], p[1], p[2], p[3]))
            f.write("\n")

        cloud_list = []
        for p in pc2.read_points(data, skip_nans=False):
            cloud_list.append(p[0])
            cloud_list.append(p[1])
            cloud_list.append(p[2])
            cloud_list.append(p[3])

        f.write("\n")

    pcd = py3d.read_point_cloud(tmp_pcd_name)

    return pcd
Exemplo n.º 2
0
import sys
import numpy as np
import py3d

sys.path.append("../Open3D/build/lib/")

print("Load a ply point cloud, print it, and render it")
pcd = py3d.read_point_cloud("/home/sanjeev309/Open3D/build/lib/TestData/fragment.ply")
print(pcd)
print(np.asarray(pcd.points))
py3d.draw_geometries([pcd])

print("Downsample the point cloud with a voxel of 0.05")
downpcd = py3d.voxel_down_sample(pcd, voxel_size=0.05)
py3d.draw_geometries([downpcd])

print("Recompute the normal of the downsampled point cloud")
py3d.estimate_normals(downpcd, search_param=py3d.KDTreeSearchParamHybrid(
    radius=0.1, max_nn=30))
py3d.draw_geometries([downpcd])
print("")

print("Load a polygon volume and use it to crop the original point cloud")
vol = py3d.read_selection_polygon_volume("/home/sanjeev309/Open3D/build/lib/TestData/Crop/cropped.json")
chair = vol.crop_point_cloud(pcd)
py3d.draw_geometries([chair])
print("")

print("Paint chair")
chair.paint_uniform_color([0, 0, 0])
py3d.draw_geometries([chair])
def example_import_function():
    from py3d import read_point_cloud
    pcd = read_point_cloud("../../TestData/ICP/cloud_bin_0.pcd")
    print(pcd)