How to use the open3d.geometry 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_OctreeNodeInfo():
    origin = [0, 0, 0]
    size = 2.0
    depth = 5
    child_index = 7

    node_info = o3d.geometry.OctreeNodeInfo(origin, size, depth, child_index)
    np.testing.assert_equal(node_info.origin, origin)
    np.testing.assert_equal(node_info.size, size)
    np.testing.assert_equal(node_info.depth, depth)
    np.testing.assert_equal(node_info.child_index, child_index)
github Ryan-Zirui-Wang / farthest-point-sampling / main_sample.py View on Github external
pcd_xyz = load_pcd(example_data)
    print("Loaded ", example_data, "with shape: ", pcd_xyz.shape)

    if n_samples > pcd_xyz.shape[0]:
        print("WARNING: required {0:d} samples but the loaded point cloud only has {1:d} points.\n "
              "Change the n_sample to {2:d}.".format(n_samples, pcd_xyz.shape[0], pcd_xyz.shape[0]))
        print("WARNING: sampling")
        n_samples = pcd_xyz.shape[0]

    fps = FPS(pcd_xyz, n_samples)
    print("Initialised FPS sampler successfully.")
    print("Running FPS over {0:d} points and geting {1:d} samples.".format(pcd_xyz.shape[0], n_samples))

    # Init visualisation
    pcd_all = o3d.geometry.PointCloud()
    pcd_all.points = o3d.utility.Vector3dVector(fps.pcd_xyz)
    pcd_all.paint_uniform_color([0, 1, 0])  # original: green

    pcd_selected = o3d.geometry.PointCloud()

    if manually_step is False:
        fps.fit()  # Get all samples.
        print("FPS sampling finished.")

        pcd_selected.points = o3d.utility.Vector3dVector(fps.get_selected_pts())
        pcd_selected.paint_uniform_color([1, 0, 0])  # selected: red

        o3d.visualization.draw_geometries([pcd_all, pcd_selected])
        print("You can step the sampling process by setting \"--manually_step\" to True and press \"N/n\".")
    else:
github intel-isl / Open3D / examples / Python / ReconstructionSystem / debug / pairwise_rgbd_alignment.py View on Github external
def test_single_pair(s, t, color_files, depth_files, intrinsic, with_opencv,
                     config):
    o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Debug)
    [success, trans,
     info] = register_one_rgbd_pair(s, t, color_files, depth_files, intrinsic,
                                    with_opencv, config)
    print(trans)
    print(info)
    print(intrinsic)
    source_rgbd_image = read_rgbd_image(color_files[s], depth_files[s], False,
                                        config)
    target_rgbd_image = read_rgbd_image(color_files[t], depth_files[t], False,
                                        config)
    source = o3d.geometry.PointCloud.create_from_rgbd_image(
        source_rgbd_image, intrinsic)
    target = o3d.geometry.PointCloud.create_from_rgbd_image(
        target_rgbd_image, intrinsic)
    draw_geometries_flip([source, target])
github intel-isl / Open3D / examples / Python / ReconstructionSystem / make_fragments.py View on Github external
def read_rgbd_image(color_file, depth_file, convert_rgb_to_intensity, config):
    color = o3d.io.read_image(color_file)
    depth = o3d.io.read_image(depth_file)
    rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
        color,
        depth,
        depth_trunc=config["max_depth"],
        convert_rgb_to_intensity=convert_rgb_to_intensity)
    return rgbd_image
github intel-isl / Open3D / examples / Python / ReconstructionSystem / refine_registration.py View on Github external
current_transformation = init_transformation
    for i, scale in enumerate(range(len(max_iter))):  # multi-scale approach
        iter = max_iter[scale]
        distance_threshold = config["voxel_size"] * 1.4
        print("voxel_size %f" % voxel_size[scale])
        source_down = source.voxel_down_sample(voxel_size[scale])
        target_down = target.voxel_down_sample(voxel_size[scale])
        if config["icp_method"] == "point_to_point":
            result_icp = o3d.registration.registration_icp(
                source_down, target_down, distance_threshold,
                current_transformation,
                o3d.registration.TransformationEstimationPointToPoint(),
                o3d.registration.ICPConvergenceCriteria(max_iteration=iter))
        else:
            source_down.estimate_normals(
                o3d.geometry.KDTreeSearchParamHybrid(radius=voxel_size[scale] *
                                                     2.0,
                                                     max_nn=30))
            target_down.estimate_normals(
                o3d.geometry.KDTreeSearchParamHybrid(radius=voxel_size[scale] *
                                                     2.0,
                                                     max_nn=30))
            if config["icp_method"] == "point_to_plane":
                result_icp = o3d.registration.registration_icp(
                    source_down, target_down, distance_threshold,
                    current_transformation,
                    o3d.registration.TransformationEstimationPointToPlane(),
                    o3d.registration.ICPConvergenceCriteria(max_iteration=iter))
            if config["icp_method"] == "color":
                result_icp = o3d.registration.registration_colored_icp(
                    source_down, target_down, voxel_size[scale],
                    current_transformation,
github intel-isl / Open3D / examples / Python / Basic / mesh_subdivision.py View on Github external
def mesh_generator():
    yield meshes.triangle()
    yield meshes.plane()
    yield o3d.geometry.TriangleMesh.create_tetrahedron()
    yield o3d.geometry.TriangleMesh.create_box()
    yield o3d.geometry.TriangleMesh.create_octahedron()
    yield o3d.geometry.TriangleMesh.create_icosahedron()
    yield o3d.geometry.TriangleMesh.create_sphere()
    yield o3d.geometry.TriangleMesh.create_cone()
    yield o3d.geometry.TriangleMesh.create_cylinder()
    yield meshes.knot()
    yield meshes.bathtub()
github AoLyu / 3D-Object-Reconstruction-with-RealSense-D435 / Basic / captureRGBDpt.py View on Github external
depth_frame = rs.disparity_transform(False).process(depth_frame)
            # depth_frame = rs.hole_filling_filter().process(depth_frame)
            
            depth_color_frame = rs.colorizer().colorize(depth_frame)
            depth_color_image = np.asanyarray(depth_color_frame.get_data())

            depth_image = np.asanyarray(depth_frame.get_data())
            color_image1 = cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR)

            cv2.namedWindow('color image', cv2.WINDOW_AUTOSIZE)
            cv2.imshow('color image', cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR))
            cv2.namedWindow('depth image', cv2.WINDOW_AUTOSIZE)
            cv2.imshow('depth image', depth_color_image )

            depth = o3d.geometry.Image(depth_image)
            color = o3d.geometry.Image(color_image)

            rgbd = o3d.geometry.RGBDImage.create_from_color_and_depth(color, depth, convert_rgb_to_intensity = False)
            pcd = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd, pinhole_camera_intrinsic)
            pcd.transform([[1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]])
            # pcd = voxel_down_sample(pcd, voxel_size = 0.003)

            pointcloud += pcd

            if not geometrie_added:
                vis.add_geometry(pointcloud)
                geometrie_added = True


            vis.update_geometry()
            vis.poll_events()
            vis.update_renderer()
github intel-isl / Open3D / examples / Python / Basic / convex_hull.py View on Github external
def mesh_generator():
    yield o3d.geometry.TriangleMesh.create_box()
    yield o3d.geometry.TriangleMesh.create_sphere()
    yield meshes.knot()
    yield meshes.bunny()
    yield meshes.armadillo()
github intel-isl / Open3D / examples / Python / Basic / pointcloud_estimate_normals.py View on Github external
def knn_generator():
    yield 'knn20', o3d.geometry.KDTreeSearchParamKNN(20)
    yield 'radius', o3d.geometry.KDTreeSearchParamRadius(0.01666)
    yield 'hybrid', o3d.geometry.KDTreeSearchParamHybrid(0.01666, 60)