Python tutorial scripts not giving expected results
Hi, I'm interested in testing the registration algorithms you have implemented/developed with a view to port or wrap them for my own C# app which uses RealSense (D400) cameras to obtain point cloud data.
I've compiled from source (using Win10, CMake 3.10, VS2017 x64) and am trying to run some of the scripts at \src\Python\Tutorial\Advanced ([fast_]global_registration and colored_pointcloud_registration) with Python 2.7 but they're not working as I think they should.
Firstly the paths to the sample data need to be updated with "Test/" added before "TestData" so it can find the files, but when it does find them and the scripts run, the visualisation windows are blank and the results printed to console suggest that nothing has occurred (eg, in coloured registration, fitness = 0 and rmse = 0 always).
If I then replace the data paths with my own ply files, the visualisations work but again the scripts don't appear to achieve their goals. The coloured registration shows a fitness of 0.0015 with RMSE of 0 but from visual inspection doesn't appear to have moved the clouds any closer to each other, the global registration has actually moved them further apart, and the fast global registration is slower than the other one and puts the two clouds at tangent to each other.
Do you think this is a problem with my environment or are others seeing similar issues too? I've attached an example pair of point clouds I've generated to test on in case they are at fault also. I have also tried with pairs of clouds with more 3D and colour features with the same (non-)results.
Thanks!
I got following results:
Point-to-point ICP
Point-to-plane ICP
Colored ICP

Few things:
- The tutorial and code examples are tuned for metric scale geometries. For example, 0.1 is 0.1 meter. Your geometry is quite large (about 60 in width) so I had scaled it with 1/30.
- I tried point-to-point ICP first, and using it as initial alignment for point-to-plane ICP and colored ICP.
- The pairs fly away if I didn't apply point to point ICP first. This seems wrong. I am checking on it.
Ok, thanks. My values were in mm so after dividing them all by 1000 it's working better now, though I'm not getting as good results as you are. Do you have any advice on how to choose the parameters like voxel size? I'm guessing it should be a function of point density so it would depend on each individual cloud rather than being a hard coded value. Would you mind sharing your code for getting the above results please?
More generally, our desired use is to stitch together point clouds taken at several angles around eg. a human limb. Do you think these algorithms are appropriate for that? My main concern is that there may not always be strong enough features in either colour or geometry to do effective matching. If not, would you be able to recommend any other techniques please?
Thanks for your time!
PS: should colored_pointcloud_registration.py#43 be current_transformation = result_icp.transformation so the colour registration uses the ICP result as an initial alignment?
Here is a script I used (maybe not the same as in my previous explanation as I played a bit more)
# Open3D: www.open3d.org
# The MIT License (MIT)
# See license file or visit www.open3d.org for details
import numpy as np
import copy
from open3d import *
def draw_registration_result_original_color(source, target, transformation):
source_temp = copy.deepcopy(source)
source_temp.transform(transformation)
draw_geometries([source_temp, target])
if __name__ == "__main__":
print("1. Load two point clouds and show initial pose")
source = read_point_cloud("/Users/jaesikpa/Downloads/testClouds/testclouda.ply")
target = read_point_cloud("/Users/jaesikpa/Downloads/testClouds/testcloudb.ply")
# some pre-processing
for i in range(len(source.points)):
source.points[i] /= 100
for i in range(len(target.points)):
target.points[i] /= 100
estimate_normals(source, KDTreeSearchParamHybrid(
radius = 0.05, max_nn = 30))
estimate_normals(target, KDTreeSearchParamHybrid(
radius = 0.05, max_nn = 30))
# 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 = registration_icp(source, target, 0.02,
current_transformation, TransformationEstimationPointToPoint())
current_transformation = result_icp.transformation
draw_registration_result_original_color(
source, target, current_transformation)
result_icp = registration_icp(source, target, 0.02,
current_transformation, TransformationEstimationPointToPlane())
current_transformation = result_icp.transformation
draw_registration_result_original_color(
source, target, result_icp.transformation)
# colored pointcloud registration
# This is implementation of following paper
# J. Park, Q.-Y. Zhou, V. Koltun,
# Colored Point Cloud Registration Revisited, ICCV 2017
voxel_radius = [ 0.04, 0.02, 0.01 ];
max_iter = [ 50, 30, 14 ];
print("3. Colored point cloud registration")
for scale in range(3):
iter = max_iter[scale]
radius = voxel_radius[scale]
print([iter,radius,scale])
print("3-1. Downsample with a voxel size %.2f" % radius)
source_down = voxel_down_sample(source, radius)
target_down = voxel_down_sample(target, radius)
print("3-2. Estimate normal.")
estimate_normals(source_down, KDTreeSearchParamHybrid(
radius = radius * 2, max_nn = 30))
estimate_normals(target_down, KDTreeSearchParamHybrid(
radius = radius * 2, max_nn = 30))
print("3-3. Applying colored point cloud registration")
result_icp = registration_colored_icp(source_down, target_down,
radius, current_transformation,
ICPConvergenceCriteria(relative_fitness = 1e-6,
relative_rmse = 1e-6, max_iteration = iter))
current_transformation = result_icp.transformation
print(result_icp)
draw_registration_result_original_color(
source, target, result_icp.transformation)
Few points:
- I rescaled geometry it with 100 to re-use scale parameters in the original script.
- I computed point cloud normal prior to using it.
- check that colored ICP slides geometry to make color map consistent.
Do you think these algorithms are appropriate for that?
I cannot clearly answer for this as I am not fully understand the challenge. However, I bet colored point cloud registration would help for your case as it jointly considers geometry and color consistency together.
#378
I was never that big on computer programming, so I can't help you out. I used to be a drug addict and had my mind messed up for a while, so I can say this, if your computer problem, is like my life, then you realize that you are so full of shit that you were thinking other people were talking to you when they weren't. I am planning to go back to college though and I am interested in learning C plus plus
On Mon, May 21, 2018, 12:02 PM jb455 [email protected] wrote:
Hi, I'm interested in testing the registration algorithms you have implemented/developed with a view to port or wrap them for my own C# app which uses RealSense (D400) cameras to obtain point cloud data.
I've compiled from source (using Win10, CMake 3.10, VS2017 x64) and am trying to run some of the scripts at \src\Python\Tutorial\Advanced ([fast_]global_registration and colored_pointcloud_registration) with Python 2.7 but they're not working as I think they should.
Firstly the paths to the sample data need to be updated with "Test/" added before "TestData" so it can find the files, but when it does find them and the scripts run, the visualisation windows are blank and the results printed to console suggest that nothing has occurred (eg, in coloured registration, fitness = 0 and rmse = 0 always).
If I then replace the data paths with my own ply files, the visualisations work but again the scripts don't appear to achieve their goals. The coloured registration shows a fitness of 0.0015 with RMSE of 0 but from visual inspection doesn't appear to have moved the clouds any closer to each other, the global registration has actually moved them further apart, and the fast global registration is slower than the other one and puts the two clouds at tangent to each other.
Do you think this is a problem with my environment or are others seeing similar issues too? I've attached an example pair of point clouds I've generated to test on in case they are at fault also. I have also tried with pairs of clouds with more 3D and colour features with the same (non-)results.
Thanks!
testClouds.zip https://github.com/IntelVCL/Open3D/files/2023189/testClouds.zip
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/IntelVCL/Open3D/issues/362, or mute the thread https://github.com/notifications/unsubscribe-auth/AjF8Y_h7uUsZykmL0sx3qwdJZgJXWzjTks5t0uUsgaJpZM4UHOgR .
@Stantheman1985 No worries. We're using the issues section of our project to track both bugs and feature requests and while we encourage people to help solve them we obviously can't and don't expect it. Best of luck on your studies 👍.
Here is a script I used (maybe not the same as in my previous explanation as I played a bit more)
# Open3D: www.open3d.org # The MIT License (MIT) # See license file or visit www.open3d.org for details import numpy as np import copy from open3d import * def draw_registration_result_original_color(source, target, transformation): source_temp = copy.deepcopy(source) source_temp.transform(transformation) draw_geometries([source_temp, target]) if __name__ == "__main__": print("1. Load two point clouds and show initial pose") source = read_point_cloud("/Users/jaesikpa/Downloads/testClouds/testclouda.ply") target = read_point_cloud("/Users/jaesikpa/Downloads/testClouds/testcloudb.ply") # some pre-processing for i in range(len(source.points)): source.points[i] /= 100 for i in range(len(target.points)): target.points[i] /= 100 estimate_normals(source, KDTreeSearchParamHybrid( radius = 0.05, max_nn = 30)) estimate_normals(target, KDTreeSearchParamHybrid( radius = 0.05, max_nn = 30)) # 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 = registration_icp(source, target, 0.02, current_transformation, TransformationEstimationPointToPoint()) current_transformation = result_icp.transformation draw_registration_result_original_color( source, target, current_transformation) result_icp = registration_icp(source, target, 0.02, current_transformation, TransformationEstimationPointToPlane()) current_transformation = result_icp.transformation draw_registration_result_original_color( source, target, result_icp.transformation) # colored pointcloud registration # This is implementation of following paper # J. Park, Q.-Y. Zhou, V. Koltun, # Colored Point Cloud Registration Revisited, ICCV 2017 voxel_radius = [ 0.04, 0.02, 0.01 ]; max_iter = [ 50, 30, 14 ]; print("3. Colored point cloud registration") for scale in range(3): iter = max_iter[scale] radius = voxel_radius[scale] print([iter,radius,scale]) print("3-1. Downsample with a voxel size %.2f" % radius) source_down = voxel_down_sample(source, radius) target_down = voxel_down_sample(target, radius) print("3-2. Estimate normal.") estimate_normals(source_down, KDTreeSearchParamHybrid( radius = radius * 2, max_nn = 30)) estimate_normals(target_down, KDTreeSearchParamHybrid( radius = radius * 2, max_nn = 30)) print("3-3. Applying colored point cloud registration") result_icp = registration_colored_icp(source_down, target_down, radius, current_transformation, ICPConvergenceCriteria(relative_fitness = 1e-6, relative_rmse = 1e-6, max_iteration = iter)) current_transformation = result_icp.transformation print(result_icp) draw_registration_result_original_color( source, target, result_icp.transformation)Few points:
- I rescaled geometry it with 100 to re-use scale parameters in the original script.
- I computed point cloud normal prior to using it.
- check that colored ICP slides geometry to make color map consistent.
Do you think these algorithms are appropriate for that?
I cannot clearly answer for this as I am not fully understand the challenge. However, I bet colored point cloud registration would help for your case as it jointly considers geometry and color consistency together.
Hello When I use this algorithm I get the following error:
- Load two point clouds and show initial pose
Traceback (most recent call last):
File "example.py", line 30, in
o3d.estimate_normals (source, search_param = o3d.KDTreeSearchParamHybrid ( AttributeError: 'module' object has no attribute 'estimate_normals'
Do you know how to fix this problem?
I assume you are using the latest version of open3d? Then you should replace lines of the kind estimate_normals(source, KDTreeSearchParamHybrid(radius = 0.05, max_nn = 30)) with source.estimate_normals(KDTreeSearchParamHybrid(radius = 0.05, max_nn = 30)).
I assume you are using the latest version of open3d? Then you should replace lines of the kind
estimate_normals(source, KDTreeSearchParamHybrid(radius = 0.05, max_nn = 30))withsource.estimate_normals(KDTreeSearchParamHybrid(radius = 0.05, max_nn = 30)).
Hello I did what you told me but I got the following error:
- Load two point clouds and show initial pose
Traceback (most recent call last):
File "example.py", line 31, in
source.open3d.estimate_normals (KDTreeSearchParamHybrid (radius = 0.05, max_nn = 30)) AttributeError: 'open3d.open3d.geometry.PointCloud' object has no attribute 'open3d'
Remove the open3d from that line of code:
source.estimate_normals(KDTreeSearchParamHybrid(radius=0.05, max_nn=30))