Skip to content

KalmanFilter

Motion and trackingclassOpenCV 5.0.0
import { KalmanFilter } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

Native object: release it with using or delete(). Factories can return null; check before calling methods.

example: samples/cpp/snippets/kalman.cpp An example using the standard Kalman filter example: samples/python/snippets/kalman.py An example using the standard Kalman filter in Python. Kalman filter class.

The class implements a standard Kalman filter http://en.wikipedia.org/wiki/Kalman_filter, [Welch95] . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get an extended Kalman filter functionality.

Note: In C API when CvKalman* kalmanFilter structure is not needed anymore, it should be released with cvReleaseKalman(&kalmanFilter)

Constructors and members

static new

Create an owned KalmanFilter object. Release native handles with using or delete().

new(dynamParams: number, measureParams: number, controlParams: number, _3: number): KalmanFilter;
4 available overloads
new(): KalmanFilter;
new(_0: number, _1: number): KalmanFilter;
new(dynamParams: number, measureParams: number, controlParams: number): KalmanFilter;
new(dynamParams: number, measureParams: number, controlParams: number, _3: number): KalmanFilter;
_0

0 argument (number).

_1

1 argument (number).

dynamParams

Dimensionality of the state.

measureParams

Dimensionality of the measurement.

controlParams

Dimensionality of the control vector.

_3

Type of the created matrices that should be CV_32F or CV_64F.

Returns

The KalmanFilter result.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

statePre

predicted state (x'(k)): x(k)=Ax(k-1)+Bu(k)

statePre: Mat;

statePost

corrected state (x(k)): x(k)=x'(k)+K(k)(z(k)-Hx'(k))

statePost: Mat;

transitionMatrix

state transition matrix (A)

transitionMatrix: Mat;

controlMatrix

control matrix (B) (not used if there is no control)

controlMatrix: Mat;

measurementMatrix

measurement matrix (H)

measurementMatrix: Mat;

processNoiseCov

process noise covariance matrix (Q)

processNoiseCov: Mat;

measurementNoiseCov

measurement noise covariance matrix (R)

measurementNoiseCov: Mat;

errorCovPre

priori error estimate covariance matrix (P'(k)): P'(k)=A*P(k-1)*At + Q)

errorCovPre: Mat;

gain

Kalman gain matrix (K(k)): K(k)=P'(k)Htinv(H*P'(k)*Ht+R)

gain: Mat;

errorCovPost

posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k)

errorCovPost: Mat;

predict

Computes a predicted state.

predict(control: Mat): Mat;
2 available overloads
predict(): Mat;
predict(control: Mat): Mat;
control

The optional input control

Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

correct

Updates the predicted state from the measurement.

correct(measurement: Mat): Mat;
measurement

The measured system parameters

Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.