Skip to content

Instantly share code, notes, and snippets.

@okanyenigun
Created September 22, 2022 13:17
Show Gist options
  • Save okanyenigun/aa1512e85e94c3af345111af0b32b4ab to your computer and use it in GitHub Desktop.
Save okanyenigun/aa1512e85e94c3af345111af0b32b4ab to your computer and use it in GitHub Desktop.
voxel create_from_triangle_mesh
import numpy as np
import open3d as o3d
import open3d_tutorial as o3dtut
#get mesh data
bunny = o3d.data.BunnyMesh()
mesh = o3d.io.read_triangle_mesh(bunny.path)
#visualize mesh
mesh.scale(1 / np.max(mesh.get_max_bound() - mesh.get_min_bound()),
center=mesh.get_center())
o3d.visualization.draw_geometries([mesh])
#create voxel grid from mesh
voxel_grid = o3d.geometry.VoxelGrid.create_from_triangle_mesh(mesh,
voxel_size=0.05)
#visualize voxel grid
o3d.visualization.draw_geometries([voxel_grid])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment