Stabilizer Class Usage Examples:¶
Stabilizer Class now includes a new zero-latency Kalman filter backend (StabilizerMode.KALMAN) in v0.3.6 for real-time stabilization of live streams. It stabilizes every frame immediately with no frame buffering. See the Kalman (Zero-Latency) tabs in the examples below, and its parameters ➶.
The stabilizer may not perform well against High-frequency jitter in video. Use at your own risk!
The stabilizer might be slower for High-Quality/Resolution videos-frames.
It is advised to enable logging on the first run for easily identifying any runtime errors.
After going through Stabilizer Class Usage Examples, Checkout more of its advanced configurations here ➶
Bare-Minimum Usage with VideoCapture Gears¶
Following is the bare-minimum code you need to get started with Stabilizer Class and various VideoCapture Gears:
You can use any VideoCapture Gear instead of CamGear in the similar manner, as shown in this usage example.
Performance Improvement in v0.3.5
Starting from v0.3.5, the Stabilizer class has been refactored to bound the Average Sliding-Window (ASW) memory to O(smoothing_radius) and real-time streaming is now possible without memory issues.
New in v0.3.6
The Kalman backend (StabilizerMode.KALMAN) was added in v0.3.6.
Kalman backend never buffers frames, so stabilize() returns a stabilized frame on every call. No warm-up None check is needed.
Bare-Minimum Usage with OpenCV¶
The VidGear's stabilizer class can also work standalone easily with any Computer Vision library such as OpenCV itself. Following is the bare-minimum code you need to get started with Stabilizer Class and OpenCV:
New in v0.3.6
The Kalman backend (StabilizerMode.KALMAN) was added in v0.3.6.
Kalman backend never buffers frames, so stabilize() returns a stabilized frame on every call. No warm-up None check is needed.
Using Stabilizer with Variable Parameters¶
Stabilizer class provide certain parameters which you can use to tweak its internal properties. The complete usage example is as follows:
New in v0.3.5
The mode parameter and the StabilizerMode enum were added in v0.3.5. Existing code that does not pass mode keeps working - defaults to StabilizerMode.ASW.
New in v0.3.6
The Kalman backend (StabilizerMode.KALMAN) was added in v0.3.6.
Kalman backend never buffers frames, so stabilize() returns a stabilized frame on every call. No warm-up None check is needed.
Using Stabilizer with WriteGear¶
VideoGear's stabilizer can be used in conjunction with WriteGear API directly without any compatibility issues. The complete usage example is as follows:
You can also add live audio input to WriteGear pipeline. See this bonus example ➶
New in v0.3.6
The Kalman backend (StabilizerMode.KALMAN) was added in v0.3.6.
Kalman backend never buffers frames, so stabilize() returns a stabilized frame on every call. No warm-up None check is needed.
Using VideoGear with Stabilizer backend¶
VideoGear API provides a special internal wrapper around Stabilizer class that enables easy stabilization for various video-streams (real-time or not) with minimum effort and writing way fewer lines of code.
The complete usage example can be found here ➶