Display Normal Vectors with Open3D. Visualization. O3Dvisualizer

Display Normal Vectors with Open3D. Visualization. O3Dvisualizer

I'm using the amazing open3d Python libary to visualize some point Cloud. I already know the normal vectors of these points that I attribute directly as follows:

pcd         = o3d.geometry.PointCloud()
pcd.points  = o3d.utility.Vector3dVector(points)
pcd.normals = o3d.utility.Vector3dVector(normals)

I am also setting a visualizer in which I insert these points as follows:

app = gui.Application.instance
app.initialize()
vis = o3d.visualization.O3DVisualizer("Open3D - 3D Text", 1024, 768)
vis.show_settings = True
vis.add_geometry("my points", pcd)
with o3d.utility.VerbosityContextManager(o3d.utility.VerbosityLevel.Debug) as cm:        
    '''visualize'''
    vis.reset_camera_to_default()
    app.add_window(vis)
    app.run()

Up to now, all of this has run as intended, however I am not able to set the visualizer in such a way that enables me to visualize the normal vectors. Apparently o3d.visualization.Visualizer() has this method get_render_option() that is said to "retrieve a RenderOption" object, and in this RenderOption object there is a point_show_normal property but I couldn't make my code (more complicated than the minimal example above) work with o3d.visualization.Visualizer(): I don't see how to use this o3d.visualization.Visualizer().get_render_option().point_show_normal.

Is there any way to show the normal vectors with with open3d.visualization.O3DVisualizer?

2 Answers

you need add two lines to your code, get the render and set point_show_normal to True:

opt = vis.get_render_option()
opt.point_show_normal = True

You can see in the documentation open3D tutorials and python examples

I hope it helps

I didn't find a solution so far, so I resorted to look at my normal vectors in another window, produced using the mayavi library rather than the open3D library. To do so, I used this simple code snippet:

 from   mayavi.mlab       import *

 P = [my list of 3D points]
 N = [my list of normal vectors]

 x = P[:, 0]                        
 y = P[:, 1]                        
 z = P[:, 2]                        
 points3d(x, y, z, color=(0, 1, 0), scale_factor=0.5)                                                                                                  

 u = N[:, 0]                        
 v = N[:, 1]                        
 w = N[:, 2]                        
 quiver3d(x, y, z, u, v, w)         
 show()

And it worked as intended. Ideally I would like to have the normal vectors displayed with the rest of the figure, but this responded to my immediate needs.

I consider this as a workaround rather than the definitive solution, so I put it here as an answer if someone else having the problem finds it useful. But my question still isn't solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.