OptrisOptrisDocumentation

Documentation/OTC SDK/OTC SDK — C++ API referencev12.0

optris::sdk::view::KalmanFilter6

6-state Kalman filter (x, y, vx, vy, w, h) for blob tracking.

Public functions

KalmanFilter6

KalmanFilter6(float x, float y, float w, float h, float process_noise, float measurement_noise)

Start a filter on a first observation, at rest.

Velocity begins at zero and the covariance begins diagonal -- 0.1 on position and size, 1.0 on velocity -- and stays diagonal. That is the thing to know about this class: there are no cross terms, so it is four scalar filters sharing a constant-velocity prediction step, not a full 6x6 Kalman filter. Size never informs position and neither informs the other axis.

Parameters

Name Description
x Box centre, in the caller's units (frame widths here).
y Box centre, in the caller's units.
w Box width, same units as x.
h Box height, same units as y.
process_noise Added to every covariance diagonal on each Predict(). Larger loosens the estimate towards the newest measurement.
measurement_noise Denominator of the gain. Larger holds on to the prediction and rejects a jumpy measurement.

Both noises are captured here and never read again, so retuning a running BlobTracker with SetConfig() changes only the tracks it creates afterwards.

Predict

void Predict()

Advance state by one timestep using the constant-velocity model.

Update

void Update(float x, float y, float w, float h)

Correct the prediction with an observed bounding box.

GetState

Detection GetState() const

Return the current estimated bounding box.

GetVelocityX

float GetVelocityX() const

Horizontal speed, in x units per Predict()/Update() cycle.

Not a filtered state in the usual sense: it is maintained as 0.7 * old + 0.3 * position innovation, outside the covariance, so it measures how wrong the prediction keeps being rather than estimating a speed. The consequence is systematic. On a mover at a steady speed it settles at about 1 / (1 + gain) of the truth, which is roughly 0.79 at the default noise settings, and it lags a change of direction by several frames. Good for a direction, an ordering, or a "faster than" threshold you calibrated yourself; not a calibrated speed. Zero until the first Update().

GetVelocityY

float GetVelocityY() const

Vertical speed, in y units per Predict()/Update() cycle. Derived exactly as GetVelocityX(), with the same under-reading.