octree-nn / ocnn-pytorch

Octree-based 3D Convolutional Neural Networks
MIT License
156 stars 17 forks source link

Unexpected single extra voxel in the octree #42

Closed GCChen97 closed 3 weeks ago

GCChen97 commented 3 weeks ago

Hi, thanks for building this cool tool. I am learning to use it.

I found that there was always an extra voxel after building the Octree from a point cloud. I've tried several meshes, and they all have extra points. I also noticed that the extra point always had one zero in its coordinate. ocnn

Below is the code:


path_ply = 'mesh_gt/buddha.ply'
mesh = trimesh.load(path_ply)
vertices = torch.tensor(mesh.vertices, dtype=torch.float32)

center = vertices.mean(0)
vertices -= center
scale = vertices.abs().max()
vertices /= scale

pts_oct = Points(vertices)
octree = Octree(7, 4)
octree.build_octree(pts_oct)

x, y, z, b = octree.xyzb(5, True)
voxels = torch.stack([x, y, z, b], dim=1)
wang-ps commented 3 weeks ago

You should strictly normalize the points into the range of [-1, 1]^3. A good practice is to normalize it into [-0.99, 0.99]^3 or [0.9, 0.9]^3 to retain some margin.

GCChen97 commented 3 weeks ago

Thanks! I just noticed this problem XD