PIXELBANKv9.1.0
Menu

Implement a function to compute the cumulative camera path from given frame-to-frame translations, a crucial step in video stabilization. This process involves calculating the integrated motion of the camera over time.

The concept of cumulative camera motion is rooted in motion estimation, where the goal is to estimate the movement of the camera between consecutive frames. This is often represented as a sequence of translations and rotations. In this case, we focus on the translation component, which can be thought of as the change in position (dx,dy)(dx, dy) between two frames.

To compute the cumulative path, we can follow these steps:

  1. Initialize the starting position at the origin (0,0)(0, 0).
  2. For each frame-to-frame translation (dx,dy)(dx, dy), update the current position by adding the translation.
  3. Record the updated position at each step.
xt+1=xt+dxyt+1=yt+dyx_{t+1} = x_t + dx \\ y_{t+1} = y_t + dy

This technique is widely used in handheld camera footage stabilization to reduce jitter and produce smoother video.

Example:

Input:
transforms = [(1, 0), (1, 1), (0, 1)]
Output:
[(0, 0), (1, 0), (2, 1), (2, 2)]
Reasoning:

Starting at origin, accumulate each motion:

Initial: (0, 0) After transform 0: (0+1, 0+0) = (1, 0) After transform 1: (1+1, 0+1) = (2, 1) After transform 2: (2+0, 1+1) = (2, 2)

Path: [(0,0), (1,0), (2,1), (2,2)]

  • This represents the camera's trajectory over 4 frames.

Constraints:

  • transforms: list of (dx, dy) frame-to-frame motions
  • Return cumulative path as list of (x, y) positions
  • Path starts at (0, 0)
  • Path length = len(transforms) + 1
solution.py

Test Results

0/0
Run code to see test results.
Cumulative Camera Motion - Easy | PixelBank