Stabilizer Class References
Stabilizer API usage examples can be found here â¶
Stabilizer API parameters are explained here â¶
Stabilizer(mode=StabilizerMode.ASW, **kwargs) ¶
Factory that returns a stabilizer instance for the requested mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode | StabilizerMode | selects the stabilization algorithm. Defaults to | ASW |
**kwargs | dict | forwarded to the selected backend's constructor (e.g. | {} |
Returns:
| Type | Description |
|---|---|
_StabilizerBase | An instance of the chosen stabilizer (subclass of |
Source code in vidgear/gears/stabilizer/__init__.py
StabilizerMode ¶
Bases: Enum
Selects the video stabilization algorithm.
| Value | Backend | Notes |
|---|---|---|
StabilizerMode.ASW | Average Sliding-Window stabilizer | Default |
StabilizerMode.KALMAN | Zero-latency Kalman-filter stabilizer | Real-time, no frame buffering |
Source code in vidgear/gears/stabilizer/__init__.py
ASWStabilizer ¶
Bases: _StabilizerBase
Average Sliding-Window Video Stabilizer.
Tracks a salient feature array over a fixed-size window of past frames and cancels perturbations relative to a normalized box-filter-smoothed path. Relies on Threaded Queue mode for error-free & ultra-fast frame handling.
Source code in vidgear/gears/stabilizer/asw.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
__init__(smoothing_radius=25, border_type='black', border_size=0, crop_n_zoom=False, logging=False) ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
smoothing_radius | int | alter averaging window size. | 25 |
border_type | str | changes the extended border type. | 'black' |
border_size | int | enables and set the value for extended border size to reduce the black borders. | 0 |
crop_n_zoom | bool | enables cropping and zooming of frames(to original size) to reduce the black borders. | False |
logging | bool | enables/disables logging. | False |
Source code in vidgear/gears/stabilizer/asw.py
clean() ¶
Cleans ASWStabilizer resources.
Source code in vidgear/gears/stabilizer/asw.py
stabilize(frame) ¶
Takes an unstabilized video frame, and returns a stabilized one (or None while the smoothing window is still filling).
Source code in vidgear/gears/stabilizer/asw.py
KalmanStabilizer ¶
Bases: _StabilizerBase
Zero-Latency Kalman-filter Video Stabilizer.
Accumulates per-frame rigid motion [dx, dy, da] into a camera trajectory and smooths it online with a vectorized constant-position Kalman filter (one independent filter per axis). Each incoming frame is warped immediately from its measured trajectory onto the filtered one, so no frames are buffered and every stabilize() call returns a frame - suitable for live streams.
Source code in vidgear/gears/stabilizer/kalman.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
__init__(process_noise=0.004, measurement_noise=0.25, border_type='black', border_size=0, crop_n_zoom=False, logging=False) ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_noise | float | process noise covariance | 0.004 |
measurement_noise | float | measurement noise covariance | 0.25 |
border_type | str | changes the extended border type. | 'black' |
border_size | int | enables and set the value for extended border size to reduce the black borders. | 0 |
crop_n_zoom | bool | enables cropping and zooming of frames(to original size) to reduce the black borders. | False |
logging | bool | enables/disables logging. | False |
Source code in vidgear/gears/stabilizer/kalman.py
clean() ¶
stabilize(frame) ¶
Takes an unstabilized video frame, and returns its stabilized version immediately (zero-latency).
Source code in vidgear/gears/stabilizer/kalman.py