Spaces:
Sleeping
Sleeping
Update src/pixel3dmm/tracking/tracker.py
Browse files1295 unmodified lines12961297129812991300130113021295 unmodified lines# `vertices` is your posed mesh: shape (1, V, 3)verts_np = vertices[0].detach().cpu().numpy()trimesh.Trimesh(faces=faces_np, vertices=verts_np, process=False).export(ply_path)return arr1295 unmodified lines129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211295 unmodified lines# `vertices` is your posed mesh: shape (1, V, 3)verts_np = vertices[0].detach().cpu().numpy()# 1) build your mesh (this will compute smooth normals automatically)mesh = trimesh.Trimesh(vertices=verts_np, faces=faces_np)# 2) fetch those normals: shape is (V,3), each component in [-1,1]normals = mesh.vertex_normals # (V,3) numpy array# 3) convert them to RGB in [0,255]:# (n+1)/2 maps [-1,1]→[0,1], then *255→[0,255]colors = ((normals + 1.0) * 0.5 * 255.0).astype(np.uint8) # (V,3)# 4) you need RGBA for many formats—just set alpha=255alpha = np.full((colors.shape[0],1), 255, dtype=np.uint8)vertex_colors = np.hstack([colors, alpha]) # (V,4)# 5) assign those as your mesh’s visual colorsmesh.visual.vertex_colors = vertex_colors# 6) export—PLY or GLB both support vertex colorsout_path = os.path.join(self.mesh_folder, f"{frame_id}.glb")mesh.export(out_path)return arr
src/pixel3dmm/tracking/tracker.py+20-1