Keypoint-Based Video Stabilization
The geometric transformations between pairs of consecutive frames can be estimated from their corresponding points. This example shows how to use corresponding keypoints to implement a simple video stabilization.
Start with a video that is fairly shaky.
Import video frames.
Comparing the timings for different keypoint methods, "Oriented FAST and rotated BRIEF" (ORB) features are used, which are computationally less expensive than the others.
Confine the search for keypoints to image regions that are known to be stable. In this particular case, use the bubble support in the lower half of the image by masking.
Compute the keypoints for all frames confined to the the region of interest.
Assuming a constant distance between camera and object, the image transformation between frames can be restricted to rigid transformations.
Accumulate the transformations from one frame to the next to obtain transformations in relation to the first frame.
Transform all frames to undo the shaky camera motion.
See the initial and stabilized video side by side.