Difference between revisions of "Stabilo video stabilizer"

From Noah.org
Jump to navigationJump to search
Line 26: Line 26:
 
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.
 
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.
  
 +
Click to download: [http://www.noah.org/downloadsvn.php?src=file:///home/svn/src/python/stabilo/stabilo.py stabilo.py]
 
<include svncat src="file:///home/svn/src/python/stabilo/stabilo.py" highlight="python" />
 
<include svncat src="file:///home/svn/src/python/stabilo/stabilo.py" highlight="python" />

Revision as of 13:08, 7 December 2007


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.

samples

This unprocessed video was shot from a paraglider. This shows a bad, shaky video.

 before

This processed video shows how the algorithm smooths the video. In this example, but offset compensation is unrestricted so you can see how the video can wrap around as the algorithm tries to chase a moving video.

 after unrestricted

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.

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