PIXELBANKv8.2.1
Menu

Trajectory Smoothing Filter

Implement camera trajectory smoothing for video stabilization. This task involves reducing the jitter in a video by smoothing the camera's motion trajectory between frames.

Video stabilization is crucial for enhancing the viewing experience, and it relies on accurately estimating the homography between consecutive frames, which describes the transformation of the camera's motion. The accumulation of these transformations yields the camera's trajectory over time. However, this trajectory is often noisy and needs to be smoothed to remove unwanted jitter.

Here are the key steps:

  1. Estimate the camera motion between frames using homography estimation techniques.
  2. Accumulate the transformations to obtain the camera trajectory.
  3. Apply a smoothing filter to the trajectory.
Tsmooth(t)=iwiT(t+i)T_{smooth}(t) = \sum_i w_i \cdot T(t+i)

This technique is widely used in handheld camera recordings and action cameras to reduce shakiness.

Example:

Input:
trajectory = [(0,0,0), (1,1,0.1), (0,2,0), (2,1,0.05), (1,2,0)]
window_size = 3
Output:
Smoothed trajectory with reduced jitter
Reasoning:

Original trajectory has jumps. Moving average over window=3:

  • Frame 2: avg of frames 1,2,3 positions Result is smoother path.

Constraints:

  • trajectory: List of (x, y, angle) camera positions per frame
  • window_size: Smoothing window
  • Return: Smoothed trajectory
Editor

Test Results

0/0
Run code to see test results.