Ejemplo n.º 1
0
def draw_registration_result(source, target, transformation):
    source_temp = copy.deepcopy(source)
    target_temp = copy.deepcopy(target)
    source_temp.paint_uniform_color([1, 0.706, 0])
    target_temp.paint_uniform_color([0, 0.651, 0.929])
    source_temp.transform(transformation)
    py3d.draw_geometries([source_temp, target_temp])
Ejemplo n.º 2
0
def draw_rgbd_images():
    color_image_filename = os.path.join(log_dir, "images", "000000_rgb.png")
    depth_image_filename = os.path.join(log_dir, "images", "000000_depth.png")

    print "color_image_filename: ", color_image_filename
    color_raw = py3d.read_image(color_image_filename)
    print "loaded rgb image"

    print "depth_image_filename: ", depth_image_filename
    depth_raw = py3d.read_image(depth_image_filename)
    print "loaded depth image"
    rgbd_image = py3d.create_rgbd_image_from_color_and_depth(
        color_raw, depth_raw)

    plt.subplot(1, 2, 1)
    plt.title('grayscale image')
    plt.imshow(rgbd_image.color)
    plt.subplot(1, 2, 2)
    plt.title('depth image')
    plt.imshow(rgbd_image.depth)
    plt.show()

    pcd = py3d.create_point_cloud_from_rgbd_image(
        rgbd_image, PinholeCameraIntrinsic.prime_sense_default)
    # Flip it, otherwise the pointcloud will be upside down
    pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
    py3d.draw_geometries([pcd])
Ejemplo n.º 3
0
import copy

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

print("Testing mesh in py3d ...")
mesh = py3d.read_triangle_mesh(
    "/home/sanjeev309/Open3D/build/lib/TestData/knot.ply")
print(mesh)
print(np.asarray(mesh.vertices))
print(np.asarray(mesh.triangles))
print("")

print("Try to render a mesh with normals (exist: " +
      str(mesh.has_vertex_normals()) + ") and colors (exist: " +
      str(mesh.has_vertex_colors()) + ")")
py3d.draw_geometries([mesh])
print("A mesh with no normals and no colors does not seem good.")

print("Computing normal and rendering it.")
mesh.compute_vertex_normals()
print(np.asarray(mesh.triangle_normals))
py3d.draw_geometries([mesh])

print("We make a partial mesh of only the first half triangles.")
mesh1 = copy.deepcopy(mesh)
mesh1.triangles = py3d.Vector3iVector(
    np.asarray(mesh1.triangles)[:len(mesh1.triangles) // 2, :])
mesh1.triangle_normals = py3d.Vector3dVector(
    np.asarray(mesh1.triangle_normals)[:len(mesh1.triangle_normals) // 2, :])
print(mesh1.triangles)
py3d.draw_geometries([mesh1])
Ejemplo n.º 4
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])
Ejemplo n.º 5
0
def draw_registration_result_original_color(source, target, transformation):
    source_temp = copy.deepcopy(source)
    source_temp.transform(transformation)
    py3d.draw_geometries([source_temp, target])
Ejemplo n.º 6
0
import sys
import py3d
import matplotlib.pyplot as plt

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

print("Read Redwood dataset")
color_raw = py3d.read_image(
    "/home/sanjeev309/Open3D/build/lib/TestData/RGBD/color/00000.jpg")
depth_raw = py3d.read_image(
    "/home/sanjeev309/Open3D/build/lib/TestData/RGBD/depth/00000.png")
rgbd_image = py3d.create_rgbd_image_from_color_and_depth(color_raw, depth_raw)
print(rgbd_image)
plt.subplot(1, 2, 1)
plt.title('Redwood grayscale image')
plt.imshow(rgbd_image.color)
plt.subplot(1, 2, 2)
plt.title('Redwood depth image')
plt.imshow(rgbd_image.depth)
plt.show()
pcd = py3d.create_point_cloud_from_rgbd_image(
    rgbd_image, py3d.PinholeCameraIntrinsic.prime_sense_default)
# Flip it, otherwise the pointcloud will be upside down
pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
py3d.draw_geometries([pcd])
print("Writing ply file")
py3d.write_point_cloud("Redwood.ply", pcd)
Ejemplo n.º 7
0
def view_pcl(pcl_data):
    py3d.draw_geometries([pcl_data])