Redwood dataset

This tutorial reads and visualizes an RGBDImage from the Redwood dataset [Choi2015].

 5# examples/Python/Basic/rgbd_redwood.py
 6
 7import open3d as o3d
 8import matplotlib.pyplot as plt
 9
10if __name__ == "__main__":
11    print("Read Redwood dataset")
12    color_raw = o3d.io.read_image("../../TestData/RGBD/color/00000.jpg")
13    depth_raw = o3d.io.read_image("../../TestData/RGBD/depth/00000.png")
14    rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
15        color_raw, depth_raw)
16    print(rgbd_image)
17
18    plt.subplot(1, 2, 1)
19    plt.title('Redwood grayscale image')
20    plt.imshow(rgbd_image.color)
21    plt.subplot(1, 2, 2)
22    plt.title('Redwood depth image')
23    plt.imshow(rgbd_image.depth)
24    plt.show()
25
26    pcd = o3d.geometry.PointCloud.create_from_rgbd_image(
27        rgbd_image,
28        o3d.camera.PinholeCameraIntrinsic(
29            o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault))
30    # Flip it, otherwise the pointcloud will be upside down
31    pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
32    o3d.visualization.draw_geometries([pcd])

The Redwood format stored depth in a 16-bit single channel image. The integer value represents the depth measurement in millimeters. It is the default format for Open3D to parse depth images.

11    print("Read Redwood dataset")
12    color_raw = o3d.io.read_image("../../TestData/RGBD/color/00000.jpg")
13    depth_raw = o3d.io.read_image("../../TestData/RGBD/depth/00000.png")
14    rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
15        color_raw, depth_raw)
16    print(rgbd_image)

The default conversion function create_rgbd_image_from_color_and_depth creates an RGBDImage from a pair of color and depth image. The color image is converted into a grayscale image, stored in float ranged in [0, 1]. The depth image is stored in float, representing the depth value in meters. print(rgbd_image) yields:

RGBDImage of size
Color image : 640x480, with 1 channels.
Depth image : 640x480, with 1 channels.
Use numpy.asarray to access buffer data.

The converted images can be rendered as numpy arrays.

18    plt.subplot(1, 2, 1)
19    plt.title('Redwood grayscale image')
20    plt.imshow(rgbd_image.color)
21    plt.subplot(1, 2, 2)
22    plt.title('Redwood depth image')
23    plt.imshow(rgbd_image.depth)
24    plt.show()

Outputs:

../../../_images/redwood_rgbd.png

The RGBD image can be converted into a point cloud, given a set of camera parameters.

26    pcd = o3d.geometry.PointCloud.create_from_rgbd_image(
27        rgbd_image,
28        o3d.camera.PinholeCameraIntrinsic(
29            o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault))
30    # Flip it, otherwise the pointcloud will be upside down
31    pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
32    o3d.visualization.draw_geometries([pcd])

Here we use PinholeCameraIntrinsicParameters.PrimeSenseDefault as default camera parameter. It has image resolution 640x480, focal length (fx, fy) = (525.0, 525.0), and optical center (cx, cy) = (319.5, 239.5). An identity matrix is used as the default extrinsic parameter. pcd.transform applies an up-down flip transformation on the point cloud for better visualization purpose. This outputs:

../../../_images/redwood_pcd.png