RGBD Odometry

An RGBD odometry finds the camera movement between two consecutive RGBD image pairs. The input are two instances of RGBDImage. The output is the motion in the form of a rigid body transformation. Open3D implements the method of [Steinbrucker2011] and [Park2017].

Read camera intrinsic

We first read the camera intrinsic matrix from a json file.

[2]:
pinhole_camera_intrinsic = o3d.io.read_pinhole_camera_intrinsic(
    "../../test_data/camera_primesense.json")
print(pinhole_camera_intrinsic.intrinsic_matrix)
[[525.    0.  319.5]
 [  0.  525.  239.5]
 [  0.    0.    1. ]]

Note:

Lots of small data structures in Open3D can be read from / written into json files. This includes camera intrinsics, camera trajectory, pose graph, etc.

Read RGBD image

This code block reads two pairs of RGBD images in the Redwood format. We refer to Redwood dataset for a comprehensive explanation.

[3]:
source_color = o3d.io.read_image("../../test_data/RGBD/color/00000.jpg")
source_depth = o3d.io.read_image("../../test_data/RGBD/depth/00000.png")
target_color = o3d.io.read_image("../../test_data/RGBD/color/00001.jpg")
target_depth = o3d.io.read_image("../../test_data/RGBD/depth/00001.png")
source_rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
    source_color, source_depth)
target_rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
    target_color, target_depth)
target_pcd = o3d.geometry.PointCloud.create_from_rgbd_image(
    target_rgbd_image, pinhole_camera_intrinsic)

Note:

Open3D assumes the color image and depth image are synchronized and registered in the same coordinate frame. This can usually be done by turning on both the synchronization and registration features in the RGBD camera settings.

Compute odometry from two RGBD image pairs

[4]:
option = o3d.pipelines.odometry.OdometryOption()
odo_init = np.identity(4)
print(option)

[success_color_term, trans_color_term,
 info] = o3d.pipelines.odometry.compute_rgbd_odometry(
     source_rgbd_image, target_rgbd_image, pinhole_camera_intrinsic, odo_init,
     o3d.pipelines.odometry.RGBDOdometryJacobianFromColorTerm(), option)
[success_hybrid_term, trans_hybrid_term,
 info] = o3d.pipelines.odometry.compute_rgbd_odometry(
     source_rgbd_image, target_rgbd_image, pinhole_camera_intrinsic, odo_init,
     o3d.pipelines.odometry.RGBDOdometryJacobianFromHybridTerm(), option)
OdometryOption class.
iteration_number_per_pyramid_level = [ 20, 10, 5, ]
max_depth_diff = 0.030000
min_depth = 0.000000
max_depth = 4.000000

This code block calls two different RGBD odometry methods. The first one is from [Steinbrucker2011]. It minimizes photo consistency of aligned images. The second one is from [Park2017]. In addition to photo consistency, it implements constraint for geometry. Both functions run in similar speed, but [Park2017] is more accurate in our test on benchmark datasets and is thus the recommended method.

Several parameters in OdometryOption():

  • minimum_correspondence_ratio: After alignment, measure the overlapping ratio of two RGBD images. If overlapping region of two RGBD image is smaller than specified ratio, the odometry module regards that this is a failure case.

  • max_depth_diff: In depth image domain, if two aligned pixels have a depth difference less than specified value, they are considered as a correspondence. Larger value induce more aggressive search, but it is prone to unstable result.

  • min_depth and max_depth: Pixels that has smaller or larger than specified depth values are ignored.

Visualize RGBD image pairs

The RGBD image pairs are converted into point clouds and rendered together. Note that the point cloud representing the first (source) RGBD image is transformed with the transformation estimated by the odometry. After this transformation, both point clouds are aligned.

[5]:
if success_color_term:
    print("Using RGB-D Odometry")
    print(trans_color_term)
    source_pcd_color_term = o3d.geometry.PointCloud.create_from_rgbd_image(
        source_rgbd_image, pinhole_camera_intrinsic)
    source_pcd_color_term.transform(trans_color_term)
    o3d.visualization.draw_geometries([target_pcd, source_pcd_color_term],
                                      zoom=0.48,
                                      front=[0.0999, -0.1787, -0.9788],
                                      lookat=[0.0345, -0.0937, 1.8033],
                                      up=[-0.0067, -0.9838, 0.1790])
if success_hybrid_term:
    print("Using Hybrid RGB-D Odometry")
    print(trans_hybrid_term)
    source_pcd_hybrid_term = o3d.geometry.PointCloud.create_from_rgbd_image(
        source_rgbd_image, pinhole_camera_intrinsic)
    source_pcd_hybrid_term.transform(trans_hybrid_term)
    o3d.visualization.draw_geometries([target_pcd, source_pcd_hybrid_term],
                                      zoom=0.48,
                                      front=[0.0999, -0.1787, -0.9788],
                                      lookat=[0.0345, -0.0937, 1.8033],
                                      up=[-0.0067, -0.9838, 0.1790])
Using RGB-D Odometry
[[ 5.20291329e-02  9.73750680e-01 -2.21591027e-01  1.09601648e+02]
 [-5.04873304e-01 -1.65798368e-01 -8.47120917e-01 -3.05225797e+01]
 [-8.61623999e-01  1.55950361e-01  4.82994378e-01  3.07566415e+01]
 [ 0.00000000e+00  0.00000000e+00  0.00000000e+00  1.00000000e+00]]
../../_images/tutorial_pipelines_rgbd_odometry_12_1.png
Using Hybrid RGB-D Odometry
[[ 0.71063376  0.35155953 -0.60943052 -1.00149191]
 [-0.7013977   0.28610813 -0.65282724  1.28504243]
 [-0.05514461  0.89137424  0.44990114  4.54599399]
 [ 0.          0.          0.          1.        ]]
../../_images/tutorial_pipelines_rgbd_odometry_12_3.png