Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get a surface normal image aligned with color and depth images? #13775

Open
Boatsure opened this issue Feb 19, 2025 · 3 comments
Open
Labels

Comments

@Boatsure
Copy link

I want to get an aligned 3-channel normal map while getting the aligned color and depth images. Each pixel position on this normal map stores the xyz normal direction of the object surface relative to the camera position.

Is there an officially recommended way to achieve this in the current version and time point? Better in python, thank you!

@MartyG-RealSense
Copy link
Collaborator

Hi @Boatsure A RealSense user at #3321 shared Python code for the method they used to obtain the surface normal of a depth image.

I was not able to find an example of a script that used both surface normals and depth-color alignment though.

@Boatsure
Copy link
Author

@MartyG-RealSense Thanks for your reply!The script you mentioned is a kind of numerical calculation method based entirely on depth image, and its accuracy is worrying.

The viewer can export .ply file in the 3D mode, which has an option of normals output. May I ask how do the normals calculated here?

@MartyG-RealSense
Copy link
Collaborator

The save_to_ply() .ply file export function has a setting called OPTION_PLY_NORMALS that exports normals when set to true. The code for controlling this function is in the librealsense SDK file 'rs_export.hpp'

https://github.com/IntelRealSense/librealsense/blob/e1688cc318457f7dd57abcdbedd3398062db3009/include/librealsense2/hpp/rs_export.hpp

If you do a web browser 'find' operation on this page for the word normals then it will highlight the sections of code related to normals calculation.

The easiest way to export a ply with normals included is to use the Export option in the 3D pointcloud mode of the RealSense Viewer tool. You can also use Python code though. The SDK's export_ply_example.py ply export Python example program uses save_to_ply() and sets normals export to true.

https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/export_ply_example.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants