📘
Trajectory Smoothing Filter
MediumStabilization
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:
- Estimate the camera motion between frames using homography estimation techniques.
- Accumulate the transformations to obtain the camera trajectory.
- Apply a smoothing filter to the trajectory.
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
Python 3.13.1
Test Results
0/0Run code to see test results.