AdamSpannbauer / python_video_stab

A Python package to stabilize videos using OpenCV
https://adamspannbauer.github.io/python_video_stab/html/index.html
MIT License
682 stars 118 forks source link

Feature request/enhancement: Translation-only mode #104

Open ScissorHill opened 4 years ago

ScissorHill commented 4 years ago

A common use case involves videos with little to no rotation. For example, videos shot using monopods, or even experienced photographers who use good handheld technique.

It would be very useful to have an option that eliminates rotation in both the detection and transformation stage.

FFMPEG's vid.stab states it as a feature, but seems to missing in the latest implentation, at least.

I'm not very knowledgeable about this, but I came across this discussion on Stack Overflow which raises some interesting points, Specifically,

Use phase-correlation (ref. http://en.wikipedia.org/wiki/Phase_correlation), if you expect only translation between two frames. OpenCV includes DFT/FFT and IFFT, see the linked wikipedia article on formulas and explanation.

Also,

However, homographies include perspective distortion and zoom as well so the result might look a bit..uncommon (or even distorted for some fast movements).

As I understand, such use cases would not require perspective distortion/zoom to change in the stabilized video.