Interpolates the motion to the output fps.
(self)
| 120 | print(f"Motion loaded ({self.motion_file}), duration: {self.duration} sec, frames: {self.input_frames}") |
| 121 | |
| 122 | def _interpolate_motion(self): |
| 123 | """Interpolates the motion to the output fps.""" |
| 124 | times = torch.arange(0, self.duration, self.output_dt, device=self.device, dtype=torch.float32) |
| 125 | self.output_frames = times.shape[0] |
| 126 | index_0, index_1, blend = self._compute_frame_blend(times) |
| 127 | self.motion_base_poss = self._lerp( |
| 128 | self.motion_base_poss_input[index_0], |
| 129 | self.motion_base_poss_input[index_1], |
| 130 | blend.unsqueeze(1), |
| 131 | ) |
| 132 | self.motion_base_rots = self._slerp( |
| 133 | self.motion_base_rots_input[index_0], |
| 134 | self.motion_base_rots_input[index_1], |
| 135 | blend, |
| 136 | ) |
| 137 | self.motion_dof_poss = self._lerp( |
| 138 | self.motion_dof_poss_input[index_0], |
| 139 | self.motion_dof_poss_input[index_1], |
| 140 | blend.unsqueeze(1), |
| 141 | ) |
| 142 | print( |
| 143 | f"Motion interpolated, input frames: {self.input_frames}, input fps: {self.input_fps}, output frames:" |
| 144 | f" {self.output_frames}, output fps: {self.output_fps}" |
| 145 | ) |
| 146 | |
| 147 | def _lerp(self, a: torch.Tensor, b: torch.Tensor, blend: torch.Tensor) -> torch.Tensor: |
| 148 | """Linear interpolation between two tensors.""" |
no test coverage detected