in contactopt/hand_object.py [0:0]
def load_from_contactpose(self, cp_obj):
"""Load HO object from ContactPose dataset"""
if not osp.isfile(cp_obj.contactmap_filename):
raise FileNotFoundError('Could not find {}'.format(cp_obj.contactmap_filename))
obj_mesh = o3dio.read_triangle_mesh(cp_obj.contactmap_filename) # Includes object mesh and contact map embedded as vertex colors
vertex_colors = np.array(obj_mesh.vertex_colors, dtype=np.float32)
self.obj_contact = np.expand_dims(util.fit_sigmoid(vertex_colors[:, 0]), axis=1) # Normalize with sigmoid, shape (V, 1)
self.obj_verts = np.array(obj_mesh.vertices, dtype=np.float32) # Keep as floats since torch uses floats
self.obj_faces = np.array(obj_mesh.triangles)
for idx, mp in enumerate(cp_obj.mano_params):
if mp is None:
continue
self.is_left = idx == 0 # Left then right
self.hand_beta = np.array(mp['betas']) # 10 shape PCA parameters
self.hand_pose = np.array(mp['pose']) # 18 dim length, first 3 ax-angle, 15 PCA pose
mTc = mp['hTm']
# mTc = np.linalg.inv(mTc) # World to object
self.hand_mTc = mTc
if self.is_left:
raise ValueError('Pipeline currently cant handle left hands')
self.run_mano()
self.calc_dist_contact(hand=True, obj=False)