isl-org / isl-org/Open3D

Wrong Pointcloud Normals estimation if Poincloud has Nans

Open
#4,115 3 comments 1 reaction 0 assignees View on GitHub
feature request geometry pointcloud
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

**Describe the bug**
Estimating Normals of a Pointcloud with Nans, results in wrong Normals (and no worning).
Function: _Pointcloud.estimate_normals()_

**To Reproduce**
To reproduce the error, please download the attached pointcloud. Extract the .zip file and load the pointcloud with numpy.
To reproduce:
```
import open3d as o3d
import numpy as np

# Your path to the attached npy file
points_path = "/path/to/pointcloud.npy"

points = np.load(points_path)
pc = o3d.geometry.PointCloud()
pc.points = o3d.utility.Vector3dVector(points[:,:3]) # We don't need the alpha color

# Index of non Nan points. Given the sensor used, we can assume that a point is either [nan, nan, nan], or valid.
# No cases like [x, Nan, z]
ind = np.where(np.isnan(points[:,0])==False)[0]

########################################################################
# For this case, we remove Nans and compute normals
pc2 = pc.select_by_index(ind)
pc2.estimate_normals(o3d.geometry.KDTreeSearchParamHybrid(radius=0.01, max_nn=30))
pc2.orient_normals_towards_camera_location([0,0,0])
pc2 = pc2.voxel_down_sample(0.005) # Down-sample for visualization

# The normals are computed as expected
o3d.visualization.draw_geometries([pc2], point_show_normal=True)

########################################################################
# For this case, we don't remove the Nans and compute the normals
pc.estimate_normals(o3d.geometry.KDTreeSearchParamHybrid(radius=0.01, max_nn=30))
pc.orient_normals_towards_camera_location([0,0,0])
# We still need to remove Nans to be able to visualize the pointcloud
pc3 = pc.select_by_index(ind)
pc3.voxel_down_sample(0.005) # Down-sample for visualization

# The normals are all orthogonal to the camera plane, and not the the points planes
o3d.visualization.draw_geometries([pc3], point_show_normal=True)
```

**Expected behavior**
Quick: return a warning, mentioning estimate normals doesn't support Pointclouds with Nans.
Ideal: Ignore Nans in the computation, compute normals for valid points, and assign Nans for Nan points

**Screenshots**

![correct_normals](https://user-images.githubusercontent.com/10115110/135373676-d640e051-72f6-4327-89da-4bb3d90faea1.png)
![wrong_normals](https://user-images.githubusercontent.com/10115110/135373668-e1e05e0b-4a62-47ee-b6cc-234dab0eeb75.png)
**Environment (please complete the following information):**

- Operating system: Ubuntu 18.04
- Python version: Python 3.6.9
- Open3D version: '0.13.0'
- Is this remote workstation?:No
- How did you install Open3D?:pip
- Compiler version (if built from source): Nan

**Additional context**
Please use this Pointcloud to reproduce the error
[ordered_pointcloud.zip](https://github.com/isl-org/Open3D/files/7255974/ordered_pointcloud.zip)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.