How to track a line using kalman filter object of computer vision toolbox?

3 views (last 30 days)
The following matlab documentation shows how to track a 2D point and estimate it's trajectory during occlusions. http://www.mathworks.in/help/vision/examples/using-kalman-filter-for-object-tracking.html
I want to implement the same idea for tracking a line. One idea I had was to track two points in the line and thus track the line, but that would require two kalman filter objects(I have intentions of tracking multiple lines, so multiple objects will be tedious). Can I implement using just one object?
trackedLocation = correct(kalmanFilter, detectedLocation);
trackedLocation = predict(kalmanFilter);
These are the code fragments for 2D pont tracking.In short, I need to add the line parameters for
detectedLocation.

Answers (1)

Dima Lisin
Dima Lisin on 19 Sep 2014
Hi Aravind,
I think it can be done in principle, but I have never tried it.
You would not be able to use the configureKalmanFilter function, which is designed to create a Kalman filter for tracking a single point. You would have to construct the vision.KalmanFilter object directly, by setting up the StateTransitionModel and the MeasurementModel.
Assuming that you want to track line segments, which move on a 2D plane and do not change their size, and assuming that you choose to use a constant velocity motion model, then your state would include (x,y) coordinates of the two end points and a single velocity vector. Your measurement would just be the coordinates of the two end points. Then you would have to set up the appropriate state transition matrix, and the matrix mapping a state to a measurement.
Things will get more complicated if your line segments move in 3D, but you only see a 2D projection, and/or if the line segments can change in length as they move.
  1 Comment
Aravind
Aravind on 20 Sep 2014
Edited: Aravind on 20 Sep 2014
Thanks for your answer, so the states should be [x1,y1,x2,y2,dx1,dy1]? The velocity vector for x2 and y2 also should be dx1, dy1 respectively, right? , Since they are part of the same line segment..
WIth this, I get the following model,
%STM F = [1 0 0 0 t 0;0 1 0 0 0 t;0 0 1 0 t 0;0 0 0 1 0 t;0 0 0 0 1 0; 0 0 0 0 0 1]
%measurement matrix H = [1 0 0 0 0 0 ;0 1 0 0 0 0;0 0 1 0 0 0;0 0 0 1 0 0]
I'm unclear on how to choose a value of t, as it is the discrete time step when a new information is processed. What is the value used in matlab?
Sorry, for asking too many questions. :)

Sign in to comment.

Categories

Find more on Computer Vision Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!