Skip to content

Stabilizer Class Parameters

 

mode

New in v0.3.5

This parameter was added in v0.3.5.

This parameter selects the underlying stabilization algorithm via the StabilizerModeenum. TheStabilizer` class factory dispatches to the matching backend.

Data-Type: StabilizerMode enum

Default Value: StabilizerMode.ASW

Accepted Values:

Value Backend Notes
StabilizerMode.ASW Average Sliding-Window stabilizer Default. Bounded O(smoothing_radius) memory
StabilizerMode.KALMAN Kalman-filter stabilizer Zero-latency, no frame buffering

Usage:

from vidgear.gears.stabilizer import Stabilizer, StabilizerMode

# default — ASW backend
stab = Stabilizer(mode=StabilizerMode.ASW, smoothing_radius=30)

# zero-latency Kalman backend
stab = Stabilizer(mode=StabilizerMode.KALMAN, measurement_noise=0.5)

 

smoothing_radius

Only applies to StabilizerMode.ASW.

This parameter can be used to alter averaging window size. It basically handles the quality of stabilization at the expense of latency and sudden panning. Larger its value, less will be panning, more will be latency and vice-versa.

Data-Type: Integer

Default Value: Its default value is 25.

Usage:

You can easily pass this parameter as follows:

Stabilizer(smoothing_radius=30)

 

process_noise

New in v0.3.6

This parameter was added in v0.3.6.

Only applies to StabilizerMode.KALMAN.

This parameter sets the Kalman filter's process noise covariance (Q), i.e. how much the true camera path is expected to move between frames. Larger values follow intentional camera motion (panning) faster but smooth less. Accepts a scalar, or a 3-element sequence for per-axis [x, y, angle] values.

Data-Type: Float (or sequence of 3 floats)

Default Value: Its default value is 4e-3.

Usage:

Stabilizer(mode=StabilizerMode.KALMAN, process_noise=1e-3)

 

measurement_noise

New in v0.3.6

This parameter was added in v0.3.6.

Only applies to StabilizerMode.KALMAN.

This parameter sets the Kalman filter's measurement noise covariance (R), i.e. how much the measured per-frame motion is trusted. Larger values smooth harder at the cost of more lag on panning. Accepts a scalar, or a 3-element sequence for per-axis [x, y, angle] values.

Data-Type: Float (or sequence of 3 floats)

Default Value: Its default value is 0.25.

Usage:

Stabilizer(mode=StabilizerMode.KALMAN, measurement_noise=0.5)

 

border_size

This parameter enables and set the value for extended border size that compensates for reduction of black borders during stabilization.

Data-Type: Integer

Default Value: Its default value is 0(no borders).

Usage:

You can easily pass this parameter as follows:

Stabilizer(border_size=10)

 

crop_n_zoom

This parameter enables cropping and zooming of frames (to original size) to reduce the black borders from being too noticeable (similar to the Stabilized, cropped and Auto-Scaled feature available in Adobe AfterEffects) during stabilization. It simply works in conjunction with the border_size parameter, i.e. when this parameter is enabled, border_size will be used for cropping border instead of extending them.

Data-Type: Boolean

Default Value: Its default value is False.

Usage:

You can easily pass this parameter as follows:

Stabilizer(border_size=10, crop_n_zoom=True)

 

border_type

This parameter can be used to change the extended border type. Valid border types are 'black', 'reflect', 'reflect_101', 'replicate' and 'wrap', learn more about it here.

Altering border_type parameter is DISABLED when crop_n_zoom is enabled!

Data-Type: String

Default Value: Its default value is 'black'.

Usage:

You can easily pass this parameter as follows:

Stabilizer(border_type='reflect')

 

logging

This parameter enables logging (if True), essential for debugging.

Data-Type: Boolean

Default Value: Its default value is False.

Usage:

Stabilizer(logging=True)