Motion: [T, 17, 3]. (x, y, z) Normalize to [-1, 1] Z is relative to the first frame's root.
(motion, scale_range=[1, 1])
| 29 | return result |
| 30 | |
| 31 | def crop_scale_3d(motion, scale_range=[1, 1]): |
| 32 | ''' |
| 33 | Motion: [T, 17, 3]. (x, y, z) |
| 34 | Normalize to [-1, 1] |
| 35 | Z is relative to the first frame's root. |
| 36 | ''' |
| 37 | result = copy.deepcopy(motion) |
| 38 | result[:,:,2] = result[:,:,2] - result[0,0,2] |
| 39 | xmin = np.min(motion[...,0]) |
| 40 | xmax = np.max(motion[...,0]) |
| 41 | ymin = np.min(motion[...,1]) |
| 42 | ymax = np.max(motion[...,1]) |
| 43 | ratio = np.random.uniform(low=scale_range[0], high=scale_range[1], size=1)[0] |
| 44 | scale = max(xmax-xmin, ymax-ymin) / ratio |
| 45 | if scale==0: |
| 46 | return np.zeros(motion.shape) |
| 47 | xs = (xmin+xmax-scale) / 2 |
| 48 | ys = (ymin+ymax-scale) / 2 |
| 49 | result[...,:2] = (motion[..., :2]- [xs,ys]) / scale |
| 50 | result[...,2] = result[...,2] / scale |
| 51 | result = (result - 0.5) * 2 |
| 52 | return result |
| 53 | |
| 54 | def flip_data(data): |
| 55 | """ |