|
a |
|
b/datasets/OUMVLP/oumvlp17.py |
|
|
1 |
import pickle |
|
|
2 |
from tqdm import tqdm |
|
|
3 |
from pathlib import Path |
|
|
4 |
import os |
|
|
5 |
import os.path as osp |
|
|
6 |
import argparse |
|
|
7 |
import logging |
|
|
8 |
|
|
|
9 |
''' |
|
|
10 |
gernerate the 17 Number of Pose Points Format from 18 Number of Pose Points |
|
|
11 |
OUMVLP 17 |
|
|
12 |
# keypoints = { |
|
|
13 |
# 0: "nose", |
|
|
14 |
# 1: "left_eye", |
|
|
15 |
# 2: "right_eye", |
|
|
16 |
# 3: "left_ear", |
|
|
17 |
# 4: "right_ear", |
|
|
18 |
# 5: "left_shoulder", |
|
|
19 |
# 6: "right_shoulder", |
|
|
20 |
# 7: "left_elbow", |
|
|
21 |
# 8: "right_elbow", |
|
|
22 |
# 9: "left_wrist", |
|
|
23 |
# 10: "right_wrist", |
|
|
24 |
# 11: "left_hip", |
|
|
25 |
# 12: "right_hip", |
|
|
26 |
# 13: "left_knee", |
|
|
27 |
# 14: "right_knee", |
|
|
28 |
# 15: "left_ankle", |
|
|
29 |
# 16: "right_ankle" |
|
|
30 |
# } |
|
|
31 |
OUMVLP 18 |
|
|
32 |
mask=[0,15,14,17,16,5,2,6,3,7,4,11,8,12,9,13,10] |
|
|
33 |
# keypoints = { |
|
|
34 |
# 0: "nose", |
|
|
35 |
# 1: "neck", |
|
|
36 |
# 2: "Rshoulder", |
|
|
37 |
# 3: "Relbow", |
|
|
38 |
# 4: "Rwrist", |
|
|
39 |
# 5: "Lshoudler", |
|
|
40 |
# 6: "Lelbow", |
|
|
41 |
# 7: "Lwrist", |
|
|
42 |
# 8: "Rhip", |
|
|
43 |
# 9: "Rknee", |
|
|
44 |
# 10: "Rankle", |
|
|
45 |
# 11: "Lhip", |
|
|
46 |
# 12: "Lknee", |
|
|
47 |
# 13: "Lankle", |
|
|
48 |
# 14: "Reye", |
|
|
49 |
# 15: "Leye", |
|
|
50 |
# 16: "Rear", |
|
|
51 |
# 17: "Lear" |
|
|
52 |
# } |
|
|
53 |
''' |
|
|
54 |
|
|
|
55 |
def ToOUMVLP17(input_path: Path, output_path: Path): |
|
|
56 |
mask=[0,15,14,17,16,5,2,6,3,7,4,11,8,12,9,13,10] |
|
|
57 |
TOTAL_SUBJECTS = 10307 |
|
|
58 |
progress = tqdm(total=TOTAL_SUBJECTS) |
|
|
59 |
|
|
|
60 |
for subject in input_path.iterdir(): |
|
|
61 |
output_subject = subject.name |
|
|
62 |
for seq in subject.iterdir(): |
|
|
63 |
output_seq = seq.name |
|
|
64 |
for view in seq.iterdir(): |
|
|
65 |
src = os.path.join(view, f"{view.name}.pkl") |
|
|
66 |
dst = os.path.join(output_path, output_subject, output_seq, view.name) |
|
|
67 |
os.makedirs(dst, exist_ok=True) |
|
|
68 |
with open(src,'rb') as f: |
|
|
69 |
srcdata = pickle.load(f) |
|
|
70 |
#[T,18,3] |
|
|
71 |
data = srcdata[...,mask,:].copy() |
|
|
72 |
# #[T,17,3] |
|
|
73 |
pkl_path = os.path.join(dst,f'{view.name}.pkl') |
|
|
74 |
pickle.dump(data,open(pkl_path,'wb')) |
|
|
75 |
progress.update(1) |
|
|
76 |
|
|
|
77 |
if __name__ == '__main__': |
|
|
78 |
parser = argparse.ArgumentParser(description='OpenGait dataset pretreatment module.') |
|
|
79 |
parser.add_argument('-i', '--input_path', default='', type=str, help='Root path of raw dataset.') |
|
|
80 |
parser.add_argument('-o', '--output_path', default='', type=str, help='Output path of pickled dataset.') |
|
|
81 |
parser.add_argument('-l', '--log_to_file', default='./pretreatment.log', type=str, help='Log file path. Default: ./pretreatment.log') |
|
|
82 |
args = parser.parse_args() |
|
|
83 |
logging.info('Begin') |
|
|
84 |
ToOUMVLP17(input_path=Path(args.input_path), output_path=Path(args.output_path)) |
|
|
85 |
logging.info('Done') |