PIXELBANKv9.1.0
Menu

Stabilization Correction

Implement a video stabilization technique by computing the per-frame correction transforms, given the original camera path and the smoothed path. This process aims to remove unwanted jitter while preserving smooth intentional motion.

The concept of motion estimation is crucial in video stabilization, as it involves tracking the movement of the camera between consecutive frames. The smoothed path represents the desired camera motion, while the original path contains unwanted jitter. The correction transform is the difference between these two paths.

To compute the correction transforms, follow these steps:

  1. Iterate over each frame in the video sequence.
  2. Calculate the difference between the smoothed and original camera positions for each frame.
Δi=Psmooth,i−Poriginal,i\Delta_i = P_{smooth,i} - P_{original,i}

This technique is widely used in handheld camera footage stabilization.

Example:

Input:
original = [(0,0), (1,0), (2,1)]
smoothed = [(0,0), (1,0.5), (2,1)]
Output:
[(0, 0), (0, 0.5), (0, 0)]
Reasoning:
  • Computing correction at each frame:

  • Frame 0: (0,0) - (0,0) = (0, 0)

  • Frame 1: (1,0.5) - (1,0) = (0, 0.5)

  • Frame 2: (2,1) - (2,1) = (0, 0)

  • Result: [(0,0), (0,0.5), (0,0)]

  • The middle frame needs a 0.5 pixel vertical correction.

Constraints:

  • original: list of (x, y) original path positions
  • smoothed: list of (x, y) smoothed path positions
  • Return list of (dx, dy) correction transforms
  • Round to 4 decimal places
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.