jakteristics icon indicating copy to clipboard operation
jakteristics copied to clipboard

Got 'Nan' when computing normals.

Open SkyeFromKindergarten opened this issue 4 years ago • 6 comments

when I run pc_normals = compute_features(pc.astype(np.float64), search_radius=0.1, feature_names=["nx","ny","nz"])

I got many ‘nan’ How can this happen?

pc_normals = compute_features(pc.astype(np.float64), search_radius=0.1, feature_names=["nx","ny","nz"]) (Pdb) print np.isnan(pc).sum() 0 (Pdb) n /home/gy/PVCNet1014/Utils.py(95)Compute_Normals() -> pc_normals = np.expand_dims(pc_normals, axis = 0) (Pdb) print np.isnan(pc_normals).sum() 318

there are 318 nans

SkyeFromKindergarten avatar Oct 21 '20 11:10 SkyeFromKindergarten

And there's no nan in input pc

SkyeFromKindergarten avatar Oct 21 '20 11:10 SkyeFromKindergarten

Could you please share with us the problematic pointcloud?

This can happen if some points are alone in your search_radius of 0.1. In this case, the query_ball_point function will return a single point and no eigenvalue is extracted. Since the normals come with the eigenvectors, the process returns NaN for these points. The default value when features cannot be calculated is NaN.

Tofull avatar Oct 21 '20 13:10 Tofull

the input pointcloud is actually an output of a neural network, that's maybe why some points are single in the radius of 0.1

So maybe I should set the radius larger?

SkyeFromKindergarten avatar Oct 22 '20 01:10 SkyeFromKindergarten

Let's try with a larger radius and give us your feedback. I am curious about your work.

Tofull avatar Oct 22 '20 13:10 Tofull

When I added the neighbor search, I had point clouds that represent geometric objects in mind... so a search radius made more sense to me than a k neighbors search (so say a flat surface means no sharp angle within 0.1 meters). While a k neighbors search could yield unbalanced properties depending on the variation of the point density.

Maybe in your case it would make more sense to use a k neighbors search instead. It's not implemented, but it could be added.

davidcaron avatar Oct 22 '20 13:10 davidcaron

I set a lager radius of 0.3 and I got less 'nan's

I find one points cloud output that makes 'nan' when computing normals, but I don't know how to upload files in github. The problematic point seems to be far away from others, so I think @davidcaron 's thought is a good way to solve this problem.

The k neighbors search is not available now, right?

SkyeFromKindergarten avatar Oct 26 '20 02:10 SkyeFromKindergarten