main Content

Vision.KalmanFilter

校正测量,状态和州估计误差协方差

Description

Kalman滤波器对象设计用于跟踪。您可以使用它来预测物理对象的未来位置,以减少检测到的位置中的噪声,或者帮助将多个物理对象与相应的轨道相关联。可以为每个物理对象配置Kalman滤波器对象,以进行多个对象跟踪。要使用卡尔曼过滤器,对象必须以恒定速度或恒定加速度移动。

创建

The Kalman filter algorithm involves two steps, prediction and correction (also known as the update step). The first step uses previous states to predict the current state. The second step uses the current measurement, such as object location, to correct the state. The Kalman filter implements a discrete time, linear State-Space System.

笔记

To make configuring a Kalman filter easier, you can use theconfigureKalmanFilter对象配置卡尔曼过滤器。它设置了用于跟踪笛卡尔坐标系中物理对象的过滤器,并以恒定速度或恒定加速度移动。统计数据沿所有维度相同。如果您需要配置具有不同假设的Kalman过滤器,请勿使用该功能,请直接使用此对象。

在状态空间系统中,状态过渡模型,一个,以及测量模型,H,,,,are set as follows:

Variable Value
一个 [[1100;0100; 0 0 1 1; 0 0 0 1]
H [[1000;0010这是给予的

Description

例子

Kalmanfilter= Vision.KalmanFilterreturns a kalman filter for a discrete time, constant velocity system.

Kalmanfilter= vision.kalmanfilter(状态TransitionModel,,,,measurementModel另外配置控制模型,b

Kalmanfilter= vision.kalmanfilter(状态TransitionModel,,,,measurementModel,,,,ControlModel,,,,name,Value配置Kalman过滤对象属性,指定为一个或多个name,Value配对参数。未指定的属性具有默认值。

特性

expand all

描述时间步长之间状态过渡的模型(一个),指定为m-by-m矩阵。一个fter the object is constructed, this property cannot be changed. This property relates to the一个variable in the state-space model.

描述状态到测量转换的模型(H),指定为n-by-m矩阵。一个fter the object is constructed, this property cannot be changed. This property relates to theHvariable in the state-space model.

model describing control input to state transformation (b),指定为m-by-l矩阵。一个fter the object is constructed, this property cannot be changed. This property relates to thebThestate空间模型中的变量。

状态 (X),指定为标量或m- 元素矢量。如果指定状态作为标量,它将扩展到m- 元素矢量。此属性与Xvariable in the state-space model.

状态estimation error covariance (p),指定为标量或m-by-m矩阵。如果指定状态Covariance作为标量,它将扩展到m-by-m对角矩阵。此属性与p状态空间系统中的变量。

过程噪声协方差(),,,,specified as a scalar or anm-by-m矩阵。如果指定processNoise作为标量,它将扩展到m-by-m对角矩阵。此属性与variable in the state-space model.

measurement noise covariance (r),,,,specified as a scalar or ann-by-n矩阵。如果指定measurementNoise作为标量,它将扩展到n-by-n对角矩阵。此属性与rvariable in the state-space model.

对象功能

使用predictand正确的functions based on detection results. Use the距离function to find the best matches.

  • 检测到跟踪对象时,请使用predictand正确的具有Kalman滤波器对象和检测测量值的功能。按以下顺序调用功能:

    [...] =预测(Kalmanfilter);[...] =正确(Kalmanfilter,,,,测量);

  • 当未检测到跟踪对象时,请致电predict功能,但没有正确的function. When the tracked object is missing or occluded, no measurement is available. Set the functions up with the following logic:

    [...] =预测(Kalmanfilter);如果测量exists [...] = correct(Kalmanfilter,,,,测量);结尾

  • 如果过去丢失后的跟踪对象可用t-1连续步骤,您可以调用predictfunctiont时代。该语法对于处理异步视频特别有用。

    对于i = 1:k [...] =预测(kalmanfilter);end [...] =正确(KalmanFilter,测量)

正确的 校正测量,状态和州估计误差协方差
predict 测量的预测
距离 Confidence value of measurement

Examples

collapse all

跟踪物理对象向一个方向移动的位置。

生成合成数据,该数据模拟以恒定速度移动的物理对象的1-D位置。

detectedLocations = num2cell(2*randn(1,40) + (1:40));

Simulate missing detections by setting some elements to empty.

dentedLocations {1} = [];为了idx = 16:25 dentedLocations {idx} = [];结尾

Create a figure to show the location of detections and the results of using the Kalman filter for tracking.

数字;抓住on;ylabel('地点');ylim([0,50]); xlabel('时间');xlim([0,长度(检测到)]);

图包含一个轴。轴是空的。

Create a 1-D, constant speed Kalman filter when the physical object is first detected. Predict the location of the object based on previous states. If the object is detected at the current time step, use its location to correct the states.

kalman = [];为了idx = 1: length(detectedLocations) location = detectedLocations{idx};ifisempty(kalman)if〜isempty(location) stateModel = [1 1;0 1]; measurementModel = [1 0]; kalman = vision.KalmanFilter(stateModel,measurementModel,“ processNoise',1E-4,'MeasurementNoise',4);kalman.state = [位置,0];结尾elsetrackedLocation = predict(kalman);if〜isempty(location) plot(idx, location,'k+');d = distance(kalman,location); title(sprintf(距离:%f',,,,d)); trackedLocation = correct(kalman,location);elsetitle(“缺少检测”);结尾暂停(0.2);情节(IDX,TrackEdlocation,'ro');结尾结尾传奇(“检测到的位置”,,,,“预测/校正位置”);

图包含一个轴。The axes with title Distance:3.126145 contains 66 objects of type line. These objects represent Detected locations, Predicted/corrected locations.

使用卡尔曼过滤器从被零均值高斯噪声损坏的随机信号中删除噪声。

Synthesize a random signal that has value of 1 and is corrupted by a zero-mean Gaussian noise with standard deviation of 0.1.

X=1;len = 100; z = x + 0.1 * randn(1,len);

使用卡尔曼过滤器从信号中删除噪音。预计状态将是恒定的,测量与状态相同。

stateTransitionModel = 1; measurementModel = 1; obj = vision.KalmanFilter(stateTransitionModel,measurementModel,“司法协助”,,,,1,,,,“ processNoise',1E-5,'MeasurementNoise',,,,1e-2); z_corr = zeros(1,len);为了IDX = 1:Len Predive(OBJ);z_corr(idx)=正确(obj,z(idx));结尾

情节结果。

图,图(x *一个(1,len),'G-');抓住on;plot(1:len,z,'b+',1:len,z_corr,'r-');传奇(“原始信号”,,,,“嘈杂信号”,,,,'Filtered signal');

图包含一个轴。The axes contains 3 objects of type line. These objects represent Original signal, Noisy signal, Filtered signal.

一个lgorithms

expand all

参考

[1]韦尔奇,格雷格和加里​​·毕晓普,一个n Introduction to the Kalman Filter,,,,TR 95–041. University of North Carolina at Chapel Hill, Department of Computer Science.

[[2] Blackman, S.带有雷达应用的多目标跟踪。一个rtech House, Inc., pp. 93, 1986.

扩展功能

Introduced in R2012b