1.加载前面处理的各种文件路径
root_path = './'
stat_path = osp.join(root_path, 'statistics')
setup_file = osp.join(stat_path, 'setup.txt')
camera_file = osp.join(stat_path, 'camera.txt')
performer_file = osp.join(stat_path, 'performer.txt')
replication_file = osp.join(stat_path, 'replication.txt')
label_file = osp.join(stat_path, 'label.txt')
skes_name_file = osp.join(stat_path, 'skes_available_name.txt')
denoised_path = osp.join(root_path, 'denoised_data')
raw_skes_joints_pkl = osp.join(denoised_path, 'raw_denoised_joints.pkl')
frames_file = osp.join(denoised_path, 'frames_cnt.txt')
2. camera = np.loadtxt(camera_file, dtype=np.int) -》加载camera.txt文件给camera
3.performer = np.loadtxt(performer_file, dtype=np.int) -》加载performer.txt赋值给performer
4.label = np.loadtxt(label_file, dtype=np.int) - 1 -》加载label.txt标签文件
5.frames_cnt = np.loadtxt(frames_file, dtype=np.int)-》加载frames_cnt.txt文件
6.skes_name = np.loadtxt(skes_name_file, dtype=np.string_)-》加载骨骼名字文件skes_available_name.txt
7.with open(raw_skes_joints_pkl, 'rb') as fr:
skes_joints = pickle.load(fr) -》遍历raw_denoised_joints.pkl文件获取骨骼关节
8.skes_joints = seq_translation(skes_joints)-》使用seq_translation方法将序列到序列的网络和注意机制进行翻译
skes_joints = align_frames(skes_joints, frames_cnt) -》对齐到相同的帧长度
9.evaluations = ['CS', 'CV']-》评估模式
for evaluation in evaluations:
split_dataset(skes_joints, label, performer, camera, evaluation, save_path)-》传入split_dataset方法将数据保存到.h5文件中
解读seq_translation方法
1.for idx, ske_joints in enumerate(skes_joints):-》从 skes_joints遍历得到id和关节点
2.num_frames = ske_joints.shape[0]-》获取总帧数
num_bodies = 1 if ske_joints.shape[1] == 75 else 2-》如果关节矩阵形状=75则是1,否则为2
3.if num_bodies == 2:
missing_frames_1 = np.where(ske_joints[:, :75].sum(axis=1) == 0)[0]-》获取帧总量如果等于0赋值给missing_frames_1
missing_frames_2 = np.where(ske_joints[:, 75:].sum(axis=1) == 0)[0]
cnt1 = len(missing_frames_1)-》获取missing_frames_1长度
cnt2 = len(missing_frames_2)
4.i = 0 -》获得actor1的“真实”第一帧
while i < num_frames:-》当i小于总帧数
if np.any(ske_joints[i, :75] != 0):
break-》跳出
i += 1
5.origin = np.copy(ske_joints[i, 3:6]) -》起源:关节2
6.for f in range(num_frames):
if num_bodies == 1:
ske_joints[f] -= np.tile(origin, 25)-》前25关节点给行为者1
else: # for 2 actors
ske_joints[f] -= np.tile(origin, 50)-》后25个给行为者2
7.if (num_bodies == 2) and (cnt1 > 0):-》如果行为者等于2且行为者1长度大于0
ske_joints[missing_frames_1, :75] = np.zeros((cnt1, 75), dtype=np.float32)-》ske_joints用0填充
8.if (num_bodies == 2) and (cnt2 > 0):-》如果行为者等于2且行为者2长度大于0
ske_joints[missing_frames_2, 75:] = np.zeros((cnt2, 75), dtype=np.float32)-》ske_joints用0填充
9.skes_joints[idx] = ske_joints -》更新节点
解读align_frames方法
作用:以相同的帧长度对齐所有序列。
1. num_skes = len(skes_joints)-》获取关节长度
max_num_frames = frames_cnt.max() -》获取帧长度的最大值
aligned_skes_joints = np.zeros((num_skes, max_num_frames, 150), dtype=np.