Overview
VStabiliserCv is a C++ library for fast 2D (X and Y offsets) and 3D (X and Y offsets + rotation) digital video stabilization. It provides two algorithm types selected by the TYPE parameter: 2D translation-only stabilization (horizontal and vertical offset) and 3D translation + rotation stabilization via the Fourier-Mellin transform. The library is designed for camera systems requiring video vibration compensation without any external dependencies — it requires only a C++17 compiler and the CMake build system. The library is written in standard C++17. The stabilization algorithm estimates inter-frame translation by cross-correlation in the frequency domain (FFT); the Fourier-Mellin type additionally estimates rotation on the log-polar magnitude spectrum. A Kalman motion filter separates vibration from intentional camera movement on every axis. It inherits the interface from VStabiliser (source code included, Apache 2.0 license), providing a standardized and interchangeable contract compatible with other VStabiliser-based implementations. The library supports various pixel formats (RGB24, BGR24, GRAY, YUV24, YUYV, UYVY, NV12, NV21, YV12, YU12.
Benchmarks
Per-frame stabilization time microseconds for 2D mode (translation only) and 3D mode (rotation + translation) at 1, 2 and 4 threads — across devices from the RPi Zero 2W to a Core i7. Test video and stabilization results with different library parameters you can check on video.
Demo video
Downloads
Documentation: GO TO DOCUMENTATION
Demo application to check algorithms performance on your video (Widows x64): DOWNLOAD
Simple interface
class VStabiliserCv: public VStabiliser
{
public:
/// Get string of current VStabiliserCv class version.
static std::string getVersion();
/// Init all video stabiliser parameters by params structure.
bool initVStabiliser(const cr::vstab::VStabiliserParams& params) override;
/// Set value to parameter with given id.
bool setParam(cr::vstab::VStabiliserParam id, float value) override;
/// Get parameter with given id.
float getParam(cr::vstab::VStabiliserParam id) override;
/// Get params.
void getParams(VStabiliserParams& params) override;
/// Execute command.
bool executeCommand(VStabiliserCommand id, float value = 0.0f) override;
/// Stabilise video frame.
bool stabilise(cr::video::Frame& src, cr::video::Frame& dst) override;
/// Get offsets: horizontal, vertical and rotation.
void getOffsets(float& dX, float& dY, float& dA) override;
/// Decode and execute command.
bool decodeAndExecuteCommand(uint8_t* data, int size) override;
};

