| 110 | |
| 111 | # TODO: use a real upsampler.. |
| 112 | def upsample(motion, last_framerate, new_framerate): |
| 113 | step = int(new_framerate / last_framerate) |
| 114 | assert step >= 1 |
| 115 | |
| 116 | # Alpha blending => interpolation |
| 117 | alpha = np.linspace(0, 1, step + 1) |
| 118 | last = np.einsum("l,...->l...", 1 - alpha, motion[:-1]) |
| 119 | new = np.einsum("l,...->l...", alpha, motion[1:]) |
| 120 | |
| 121 | chuncks = (last + new)[:-1] |
| 122 | output = np.concatenate(chuncks.swapaxes(1, 0)) |
| 123 | # Don't forget the last one |
| 124 | output = np.concatenate((output, motion[[-1]])) |
| 125 | return output |
| 126 | |
| 127 | |
| 128 | if __name__ == "__main__": |