Stabilo video stabilizer

From Noah.org
Jump to navigationJump to search


stabilo -- video stabilization filter

This script processes successive frames of a video stream and finds the offset between each frame. It then adjust each frame of the output to minimize the offset. The result is smoother video.

This is a working alpha project at the moment.

This requires a patch to PIL Imaging-1.1.6 to add an RMS function, difference_rms(), to the ImageChops module. This function will calculate the RMS difference between two images. I could have implemented this in pure Python, but writing the function in C yielded a 10X speed increase. This video filter processing is slow to begin with, so any whole factors of speed increase is a great help.

the source

The code is fairly simple. Currently the algorithm does not check if rotation of the image will improve smoothness. Rotations are very slow and don't help much. I have code stubbed out to add this feature as a final enhancement once a good translation offset is found.

The algorithm is fairly stupid -- it's a O(N^2) search. I have a few ideas for improving this. One way would be by sampling different offsets and ignoring regions that hurt smoothness and then returning to regions that improved smoothness.

<include svncat src="file:///home/svn/src/python/stabilo/stabilo.py" highlight="python" />