varora commited on
Commit ·
4a7553f
1
Parent(s): c186c4c
add hit vis script
Browse files- vis_hit_sample.py +64 -0
vis_hit_sample.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import load_dataset
|
| 2 |
+
import open3d as o3d
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
def vis_hit_sample(sample):
|
| 6 |
+
# get point-cloud from sample
|
| 7 |
+
pc = np.asarray(sample['body_cont_pc'])
|
| 8 |
+
# create point-cloud
|
| 9 |
+
pcd = o3d.geometry.PointCloud()
|
| 10 |
+
pcd.points = o3d.utility.Vector3dVector(pc)
|
| 11 |
+
pcd.paint_uniform_color([0.6509803922, 0.2901960784, 0.2823529412])
|
| 12 |
+
pcd_front = pcd.__copy__()
|
| 13 |
+
|
| 14 |
+
# get mesh and mesh-free-verts from sample
|
| 15 |
+
mesh_verts = np.asarray(sample['smpl_dict']['verts'])
|
| 16 |
+
mesh_verts_free = np.asarray(sample['smpl_dict']['verts_free'])
|
| 17 |
+
mesh_faces = np.asarray(sample['smpl_dict']['faces'])
|
| 18 |
+
# create mesh
|
| 19 |
+
mesh = o3d.geometry.TriangleMesh()
|
| 20 |
+
mesh.vertices = o3d.utility.Vector3dVector(mesh_verts)
|
| 21 |
+
mesh.triangles = o3d.utility.Vector3iVector(mesh_faces)
|
| 22 |
+
mesh.paint_uniform_color([0.737254902, 0.7960784314, 0.8196078431])
|
| 23 |
+
# create mesh-free-verts
|
| 24 |
+
mesh_free = o3d.geometry.TriangleMesh()
|
| 25 |
+
mesh_free.vertices = o3d.utility.Vector3dVector(mesh_verts_free)
|
| 26 |
+
mesh_free.triangles = o3d.utility.Vector3iVector(mesh_faces)
|
| 27 |
+
mesh_free.paint_uniform_color([0.737254902, 0.7960784314, 0.8196078431])
|
| 28 |
+
|
| 29 |
+
# visualize sample
|
| 30 |
+
vis = o3d.visualization.Visualizer()
|
| 31 |
+
vis.create_window()
|
| 32 |
+
vis.get_render_option().point_size = 2
|
| 33 |
+
xyz = (-np.pi / 2, 0, 0)
|
| 34 |
+
R1 = o3d.geometry.get_rotation_matrix_from_xyz(xyz)
|
| 35 |
+
xyz = (0, 2 * np.pi, 0)
|
| 36 |
+
R2 = o3d.geometry.get_rotation_matrix_from_xyz(xyz)
|
| 37 |
+
vis.add_geometry(mesh.rotate(R1, center=(0, 0, 0))) # side view
|
| 38 |
+
vis.add_geometry(mesh_free.translate((1.2, 0, 0)))
|
| 39 |
+
vis.add_geometry(mesh_free.rotate(R1, center=(0, 0, 0))) # side view
|
| 40 |
+
vis.add_geometry(pcd.rotate(R1, center=(0, 0, 0))) # side view
|
| 41 |
+
vis.add_geometry(pcd_front.translate((1.2, 0, 0)))
|
| 42 |
+
vis.add_geometry(pcd_front.rotate(R1, center=(0, 0, 0))) # side view
|
| 43 |
+
vis.get_render_option().mesh_show_wireframe = True
|
| 44 |
+
vis.get_render_option().light_on = True
|
| 45 |
+
vis.get_render_option().mesh_show_back_face = True
|
| 46 |
+
vis.get_render_option().mesh_shade_option = o3d.visualization.MeshShadeOption.Default
|
| 47 |
+
vis.poll_events()
|
| 48 |
+
vis.update_renderer()
|
| 49 |
+
vis.run()
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
if __name__ == '__main__':
|
| 53 |
+
# male splits
|
| 54 |
+
male_train = load_dataset("varora/hit", "male", split="train")
|
| 55 |
+
#male_val = load_dataset("varora/hit", "male", split="validation")
|
| 56 |
+
#male_test = load_dataset("varora/hit", "male", split="test")
|
| 57 |
+
|
| 58 |
+
# female splits
|
| 59 |
+
#female_train = load_dataset("varora/hit", "female", split="train")
|
| 60 |
+
#female_val = load_dataset("varora/hit", "female", split="validation")
|
| 61 |
+
#female_test = load_dataset("varora/hit", "female", split="test")
|
| 62 |
+
|
| 63 |
+
hit_sample = male_train[0]
|
| 64 |
+
vis_hit_sample(hit_sample)
|