Skip to content
New issue

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

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

Already on GitHub? # to your account

wrong estimate_point_cloud_normals #1577

Open
l1346792580123 opened this issue Jun 28, 2023 · 3 comments
Open

wrong estimate_point_cloud_normals #1577

l1346792580123 opened this issue Jun 28, 2023 · 3 comments

Comments

@l1346792580123
Copy link

🐛 Bugs / Unexpected behaviors

the results of estimate_point_cloud_normals are wrong.

Instructions To Reproduce the Issue:

I use the bunny obj from here. and the code is

import trimesh
import open3d
from pytorch3d.ops.points_normals import estimate_pointcloud_normals
from pytorch3d.structures.pointclouds import Pointclouds
mesh = trimesh.load('bunny.obj', process=False, maintain_order=True)
points,face_idx = trimesh.sample.sample_surface_even(mesh, 40960)
np.savetxt('tmp.xyz', points)

pcd = open3d.io.read_point_cloud('tmp.xyz')
pcd.estimate_normals()
normals1 = np.asarray(pcd.normals)

points2 = torch.from_numpy(points.astype(np.float32)).unsqueeze(0).cuda()
pointclouds = Pointclouds(points2)
normals2 = estimate_pointcloud_normals(pointclouds, 10)
normals2 = normals2.squeeze().detach().cpu().numpy()

normals1 = (normals1+1) / 2
normals2 = (normals2+1) / 2

np.savetxt('a.txt', np.concatenate([points,normals1],axis=1))
np.savetxt('b.txt', np.concatenate([points,normals2],axis=1))

The visual results of open3d and pytorch3d are as followed.

a
b

@bottler
Copy link
Contributor

bottler commented Jun 28, 2023

Both the images look a little surprising: The upper one varies less than I'd expect, and the lower varies more than I'd expect, assuming you are mapping the normal to color space. Can you investigate the plotting, and perhaps plot the normals as arrows? And what happens when you vary the neighborhood_size and set disambiguate_directions=False?

@l1346792580123
Copy link
Author

The arrow results of open3d and neighborhood_size=10,30,50, disambiguate_directions=True, are shown below
open3d
10_true
30_true
50_true

and the result of neighborhood_size=50,disambiguate_direction=False is shown below

50_false

@l1346792580123
Copy link
Author

I found the wrong normal vectors come from the wrong output of symeig3x3. When I set use_symeig_workaround=False the results are normal.

Moreover, I found that the normal vectors are more consistency when setting disambiguate_directions=False, which is the opposite of what the parameter originally intended. The results of disambiguate_directions=False,use_symeig_workaround=False and disambiguate_directions=True,use_symeig_workaround=False are shown below

snapshot00

snapshot01

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

No branches or pull requests

2 participants