| 30 | plys2npy(params.ply_dir, params.out_dir) |
| 31 | |
| 32 | def plys2npy(ply_dir, out_dir): |
| 33 | ply_dir = Path(ply_dir) |
| 34 | paths = [] |
| 35 | file_list = natsort.natsorted(os.listdir(ply_dir)) |
| 36 | for item in file_list: |
| 37 | if item.endswith(".ply") and not item.endswith("_gt.ply"): |
| 38 | paths.append(os.path.join(ply_dir, item)) |
| 39 | |
| 40 | |
| 41 | meshs = np.zeros((len(paths), 6890, 3)) |
| 42 | for i, path in enumerate(paths): |
| 43 | mesh = trimesh.load_mesh(path, process=False) |
| 44 | vs = mesh.vertices |
| 45 | assert vs.shape == (6890, 3) |
| 46 | meshs[i] = vs |
| 47 | |
| 48 | basename = os.path.basename(ply_dir) |
| 49 | if basename.startswith("SMPLFit_"): |
| 50 | basename = basename[len("SMPLFit_"):] |
| 51 | file_name = os.path.join(out_dir, basename+ "_mesh.npy") |
| 52 | np.save(file_name, meshs) |
| 53 | |
| 54 | |
| 55 | if __name__ == "__main__": |