pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

wrong estimate_point_cloud_normals

Open l1346792580123 opened this issue 1 year ago • 3 comments

🐛 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

l1346792580123 avatar Jun 28 '23 09:06 l1346792580123

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?

bottler avatar Jun 28 '23 11:06 bottler

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 avatar Jun 28 '23 14:06 l1346792580123

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

l1346792580123 avatar Sep 07 '23 08:09 l1346792580123