processes the 1x12 raw pose from dataset by aligning and then normalizing produce logq :param poses_in: N x 12 :param mean_t: 3 :param std_t: 3 :param align_R: 3 x 3 :param align_t: 3 :param align_s: 1 :return: processed poses (translation + log quaternion) N x 6
(poses_in, mean_t, std_t, align_R, align_t, align_s)
| 96 | return poses_out |
| 97 | |
| 98 | def process_poses_logq(poses_in, mean_t, std_t, align_R, align_t, align_s): |
| 99 | """ |
| 100 | processes the 1x12 raw pose from dataset by aligning and then normalizing |
| 101 | produce logq |
| 102 | :param poses_in: N x 12 |
| 103 | :param mean_t: 3 |
| 104 | :param std_t: 3 |
| 105 | :param align_R: 3 x 3 |
| 106 | :param align_t: 3 |
| 107 | :param align_s: 1 |
| 108 | :return: processed poses (translation + log quaternion) N x 6 |
| 109 | """ |
| 110 | poses_out = np.zeros((len(poses_in), 6)) # (1000,6) |
| 111 | poses_out[:, 0:3] = poses_in[:, [3, 7, 11]] # x,y,z position |
| 112 | # align |
| 113 | for i in range(len(poses_out)): |
| 114 | R = poses_in[i].reshape((3, 4))[:3, :3] # rotation |
| 115 | q = txq.mat2quat(np.dot(align_R, R)) |
| 116 | q *= np.sign(q[0]) # constrain to hemisphere, first number, +1/-1, q.shape (1,4) |
| 117 | q = qlog(q) # (1,3) |
| 118 | poses_out[i, 3:] = q # logq rotation |
| 119 | t = poses_out[i, :3] - align_t |
| 120 | poses_out[i, :3] = align_s * np.dot(align_R, t[:, np.newaxis]).squeeze() |
| 121 | |
| 122 | # normalize translation |
| 123 | poses_out[:, :3] -= mean_t #(1000, 6) |
| 124 | poses_out[:, :3] /= std_t |
| 125 | return poses_out |
| 126 | |
| 127 | from torchvision.datasets.folder import default_loader |
| 128 | def load_image(filename, loader=default_loader): |