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, TYPE 0) and 3D translation + rotation stabilization (TYPE 1). The library has no mandatory third-party dependencies: it is written in standard C++17 and needs only a C++17 compiler, the CMake build system and the Frame, ConfigReader and VStabiliser libraries. For every frame the library measures the motion of the image against the previous frame, filters the measured motion separately on every axis (steady camera movement such as a pan is followed, shaking is compensated) and shifts or rotates the frame by the resulting correction. The FFT used internally is part of the library; its SIMD level (AVX2, SSE2, NEON or portable C++) is selected at run time from the CPU features. Optionally, if EGL and OpenGL ES 3.0 are found at build time, the output warp (rotation together with the sub-pixel offset) of the packed three-byte formats (RGB24, BGR24 and YUV24) is executed on the GPU, falling back to the CPU warp automatically when the device has no working GL driver. It inherits the interface from the VStabiliser interface library, providing a standardized and interchangeable contract compatible with other VStabiliser-based implementations. The library supports the RAW pixel formats RGB24, BGR24, GRAY, YUV24, YUYV, UYVY, NV12, NV21, YV12 and YU12 of the Frame class (Frame library).
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;
};

