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:
- Iterate over each frame in the video sequence.
- Calculate the difference between the smoothed and original camera positions for each frame.
This technique is widely used in handheld camera footage stabilization.
Example
original = [(0,0), (1,0), (2,1)] smoothed = [(0,0), (1,0.5), (2,1)]
[(0, 0), (0, 0.5), (0, 0)]
- Inputs:
originalis the camera's measured position in each of 3 frames, jitter included;smoothedis where the camera should have been in the same 3 frames. Frame of one list pairs with frame of the other. - Math: the correction is the vector that moves the shaky position onto the smooth one, , taken separately for and .
- Frame 0: , already on the smooth path.
- Frame 1: , the measured fell short of the smooth path, so the correction adds in only.
- Frame 2: .
- Output: one pair per frame, rounded to 4 decimal places:
[(0, 0), (0, 0.5), (0, 0)]. Notice the sign: if the smooth path were below the original, the correction would be negative, e.g. original with smoothed gives .
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