How to use the open3d.io.read_point_cloud function in open3d

To help you get started, we’ve selected a few open3d examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intel-isl / Open3D / src / UnitTest / Python / test_octree.py View on Github external
def test_octree_voxel_grid_convert():
    pwd = os.path.dirname(os.path.realpath(__file__))
    data_dir = os.path.join(pwd, os.pardir, os.pardir, os.pardir, "examples",
                            "TestData")
    pcd_path = os.path.join(data_dir, "fragment.ply")
    pcd = o3d.io.read_point_cloud(pcd_path)
    octree = o3d.geometry.Octree(8)
    octree.convert_from_point_cloud(pcd)

    voxel_grid = octree.to_voxel_grid()
    octree_copy = voxel_grid.to_octree(max_depth=8)
github intel-isl / Open3D / src / UnitTest / Python / test_octree.py View on Github external
def test_locate_leaf_node():
    pwd = os.path.dirname(os.path.realpath(__file__))
    data_dir = os.path.join(pwd, os.pardir, os.pardir, os.pardir, "examples",
                            "TestData")
    pcd_path = os.path.join(data_dir, "fragment.ply")
    pcd = o3d.io.read_point_cloud(pcd_path)

    max_depth = 5
    octree = o3d.geometry.Octree(max_depth)
    octree.convert_from_point_cloud(pcd, 0.01)

    # Try locating a few points
    for idx in range(0, len(pcd.points), 200):
        point = pcd.points[idx]
        node, node_info = octree.locate_leaf_node(np.array(point))
        # The located node must be in bound
        assert octree.is_point_in_bound(point, node_info.origin, node_info.size)
        # Leaf node must be located
        assert node_info.depth == max_depth
        # Leaf node's size must match
        assert node_info.size == octree.size / np.power(2, max_depth)
github intel-isl / Open3D / examples / Python / Basic / clustering.py View on Github external
mesh = o3d.geometry.TriangleMesh.create_torus().scale(5)
    mesh += o3d.geometry.TriangleMesh.create_torus()
    yield "torus", mesh.sample_points_uniformly(int(1e4)), 0.75

    d = 4
    mesh = o3d.geometry.TriangleMesh.create_tetrahedron().translate((-d, 0, 0))
    mesh += o3d.geometry.TriangleMesh.create_octahedron().translate((0, 0, 0))
    mesh += o3d.geometry.TriangleMesh.create_icosahedron().translate((d, 0, 0))
    mesh += o3d.geometry.TriangleMesh.create_torus().translate((-d, -d, 0))
    mesh += o3d.geometry.TriangleMesh.create_moebius(twists=1).translate(
        (0, -d, 0))
    mesh += o3d.geometry.TriangleMesh.create_moebius(twists=2).translate(
        (d, -d, 0))
    yield "shapes", mesh.sample_points_uniformly(int(1e5)), 0.5

    yield "fragment", o3d.io.read_point_cloud(
        "../../TestData/fragment.ply"), 0.02
github chrischoy / FCGF / util / pointcloud.py View on Github external
def prepare_pointcloud(filename, voxel_size):
  pcd = o3d.io.read_point_cloud(filename)
  T = get_random_transformation(pcd)
  pcd.transform(T)
  pcd_down = pcd.voxel_down_sample(voxel_size)
  return pcd_down, T
github intel-isl / Open3D / examples / Python / Basic / pointcloud.py View on Github external
# Open3D: www.open3d.org
# The MIT License (MIT)
# See license file or visit www.open3d.org for details

# examples/Python/Basic/pointcloud.py

import numpy as np
import open3d as o3d

if __name__ == "__main__":

    print("Load a ply point cloud, print it, and render it")
    pcd = o3d.io.read_point_cloud("../../TestData/fragment.ply")
    print(pcd)
    print(np.asarray(pcd.points))
    o3d.visualization.draw_geometries([pcd])

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

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

    print("Print a normal vector of the 0th point")
    print(downpcd.normals[0])
    print("Print the normal vectors of the first 10 points")
github Maximellerbach / AutonomousCar / pseudo-slam(experimental) / points3D.py View on Github external
def load_mesh(self, path=""):
        self.mesh = o3d.io.read_point_cloud(path)
github intel-isl / Open3D / examples / Python / Basic / file_io.py View on Github external
# Open3D: www.open3d.org
# The MIT License (MIT)
# See license file or visit www.open3d.org for details

# examples/Python/Basic/file_io.py

import open3d as o3d

if __name__ == "__main__":

    print("Testing IO for point cloud ...")
    pcd = o3d.io.read_point_cloud("../../TestData/fragment.pcd")
    print(pcd)
    o3d.io.write_point_cloud("copy_of_fragment.pcd", pcd)

    print("Testing IO for meshes ...")
    mesh = o3d.io.read_triangle_mesh("../../TestData/knot.ply")
    print(mesh)
    o3d.io.write_triangle_mesh("copy_of_knot.ply", mesh)

    print("Testing IO for textured meshes ...")
    textured_mesh = o3d.io.read_triangle_mesh("../../TestData/crate/crate.obj")
    print(textured_mesh)
    o3d.io.write_triangle_mesh("copy_of_crate.obj",
                               textured_mesh,
                               write_triangle_uvs=True)
    copy_textured_mesh = o3d.io.read_triangle_mesh('copy_of_crate.obj')
    print(copy_textured_mesh)
github intel-isl / Open3D / examples / Python / Advanced / colored_pointcloud_registration.py View on Github external
import numpy as np
import copy
import open3d as o3d


def draw_registration_result_original_color(source, target, transformation):
    source_temp = copy.deepcopy(source)
    source_temp.transform(transformation)
    o3d.visualization.draw_geometries([source_temp, target])


if __name__ == "__main__":

    print("1. Load two point clouds and show initial pose")
    source = o3d.io.read_point_cloud("../../TestData/ColoredICP/frag_115.ply")
    target = o3d.io.read_point_cloud("../../TestData/ColoredICP/frag_116.ply")

    # draw initial alignment
    current_transformation = np.identity(4)
    draw_registration_result_original_color(source, target,
                                            current_transformation)

    # point to plane ICP
    current_transformation = np.identity(4)
    print("2. Point-to-plane ICP registration is applied on original point")
    print("   clouds to refine the alignment. Distance threshold 0.02.")
    result_icp = o3d.registration.registration_icp(
        source, target, 0.02, current_transformation,
        o3d.registration.TransformationEstimationPointToPlane())
    print(result_icp)
    draw_registration_result_original_color(source, target,
                                            result_icp.transformation)
github intel-isl / Open3D / examples / Python / Advanced / interactive_visualization.py View on Github external
def demo_manual_registration():
    print("Demo for manual ICP")
    source = o3d.io.read_point_cloud("../../TestData/ICP/cloud_bin_0.pcd")
    target = o3d.io.read_point_cloud("../../TestData/ICP/cloud_bin_2.pcd")
    print("Visualization of two point clouds before manual alignment")
    draw_registration_result(source, target, np.identity(4))

    # pick points from two point clouds and builds correspondences
    picked_id_source = pick_points(source)
    picked_id_target = pick_points(target)
    assert (len(picked_id_source) >= 3 and len(picked_id_target) >= 3)
    assert (len(picked_id_source) == len(picked_id_target))
    corr = np.zeros((len(picked_id_source), 2))
    corr[:, 0] = picked_id_source
    corr[:, 1] = picked_id_target

    # estimate rough transformation using correspondences
    print("Compute a rough transform using the correspondences given by user")
    p2p = o3d.registration.TransformationEstimationPointToPoint()