Tracking Pedestrians from a Moving Car
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Darelle Luis Tolentino
el 1 de Mayo de 2023
Editada: Kevin Holly
el 1 de Mayo de 2023
Can someone help me, What is the Matlab code syntax for calling the Kalman filter?
Using the sample code in this link: Tracking Pedestrians from a Moving Car - MATLAB & Simulink (mathworks.com)
0 comentarios
Respuesta aceptada
Kevin Holly
el 1 de Mayo de 2023
Editada: Kevin Holly
el 1 de Mayo de 2023
Here the Kalman filter object is created
% Create a Kalman filter object.
kalmanFilter = configureKalmanFilter('ConstantVelocity', ...
centroid, [2, 1], [5, 5], 100);
% Create an array of tracks, where each
% track is a structure representing a moving object in the video.
function tracks = initializeTracks()
% Create an empty array of tracks
tracks = struct(...
'id', {}, ...
'color', {}, ...
'bboxes', {}, ...
'scores', {}, ...
'kalmanFilter', {}, ...
'age', {}, ...
'totalVisibleCount', {}, ...
'confidence', {}, ...
'predPosition', {});
end
open vision.KalmanFilter
Within it, you can see the different functions that can be called.
% predict method syntax:
%
% [z_pred, x_pred, P_pred] = predict(obj) returns the prediction of
% measurement, state, and state estimation error covariance at the next
% time step (e.g., next video frame). The internal state and covariance
% of Kalman filter are overwritten by the prediction results.
%
% [z_pred, x_pred, P_pred] = predict(obj, u) additionally, lets you
% specify the control input, u, an L-element vector. This syntax applies
% if you have set the control model B.
%
% correct method syntax:
%
% [z_corr, x_corr, P_corr] = correct(obj, z) returns the correction of
% measurement, state, and state estimation error covariance based on the
% current measurement z, an N-element vector. The internal state and
% covariance of Kalman filter are overwritten by the corrected values.
%
% distance method syntax:
%
% d = distance(obj, z_matrix) computes a distance between one or more
% measurements supplied by the z_matrix and the measurement predicted by
% the Kalman filter object. This computation takes into account the
% covariance of the predicted state and the process noise. Each row of
% the input z_matrix must contain a measurement vector of length N. The
% distance method returns a row vector where each element is a distance
% associated with the corresponding measurement input. The distance
% method can only be called after the predict method.
%
% Notes:
% ------
% - If the measurement exists, e.g., the object has been detected, you
% can call the predict method and the correct method together. If the
% measurement is missing, you can call the predict method but not the
% correct method.
%
% If the object is detected
% predict(kalmanFilter);
% trackedLocation = correct(kalmanFilter, objectLocation);
% Else
% trackedLocation = predict(kalmanFilter);
% End
%
% - You can use the distance method to compute distances that describe
% how a set of measurements matches the Kalman filter. You can thus
% find a measurement that best fits the filter. This strategy can be
% used for matching object detections against object tracks in a
% multi-object tracking problem.
%
% - You can use configureKalmanFilter to create a Kalman filter for
% object tracking.
%
% KalmanFilter methods:
%
% predict - Predicts the measurement, state, and state estimation error covariance
% correct - Corrects the measurement, state, and state estimation error covariance
% distance - Computes distances between measurements and the Kalman filter
% clone - Creates a tracker object with the same property values
%
So, in the case above,
predict(kalmanFilter)
correct(kalmanFilter)
or if you are pulling the kalmanFilter from the newTrack:
predict(track(i).kalmanFilter)
correct(track(i).kalmanFilter)
where i is the index of the array of tracks
If you are unfamilar with object-oriented programming, I would take the free onramp training:
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Tracking and Motion Estimation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!