diff --git a/apps/postprocess/vertices_to_bounds.py b/apps/postprocess/vertices_to_bounds.py new file mode 100644 index 0000000..2467bb5 --- /dev/null +++ b/apps/postprocess/vertices_to_bounds.py @@ -0,0 +1,24 @@ +import os +import numpy as np +from tqdm import tqdm +from easymocap.mytools.reader import read_json +from os.path import join + +if __name__ == '__main__': + import argparse + parser = argparse.ArgumentParser() + parser.add_argument('path', type=str) + parser.add_argument('--debug', action='store_true') + args = parser.parse_args() + + verticesnames = os.listdir(args.path) + bounds = [] + for vertname in tqdm(verticesnames): + vertices = read_json(join(args.path, vertname)) + bounds_frame = [] + for data in vertices: + verts = np.array(data['vertices']) + bound = np.array([verts.min(axis=0), verts.max(axis=0)]) + bounds_frame.append(bound) + bounds.append(bounds_frame) + np.save('test.npy', np.stack(bounds)) \ No newline at end of file