Last active
June 22, 2023 03:50
-
-
Save justinhchae/e4f7d913796070607bf04ce4b0221fff to your computer and use it in GitHub Desktop.
Sampling points with PyTorch3D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install direct from our forked repository: https://github.com/Esri/pytorch3d/tree/multitexture-obj-high-precision | |
!pip install 'git+https://github.com/Esri/pytorch3d.git@multitexture-obj-high-precision' | |
from pytorch3d.ops import sample_points_from_obj | |
( | |
points, # points sampled proportional to face area | |
normals, # point normals based on mesh verts | |
textures, # point textures sampled from faces | |
mappers # an index to each points origin face | |
) = sample_points_from_obj( | |
verts=obj[0], | |
faces=obj[1].verts_idx, | |
verts_uvs=obj[2].verts_uvs, | |
faces_uvs=obj[1].textures_idx, | |
texture_images=obj[2].texture_images, | |
materials_idx=obj[1].materials_idx, | |
texture_atlas=obj[2].texture_atlas, | |
sample_all_faces=True, # optionally force sampler to provide at least one point per face | |
min_sampling_factor=100, # control how dense the point cloud is where 0 is least dense and 1000 is very dense | |
return_mappers=True, # whether to return the point to face mapping | |
return_textures=True, # whether to return textures per point | |
return_normals=True # whether to return normals per point | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment