1

I am currently trying to use Kanade-Lucas-Tomasi tracker in MATLAB as used in this example: Face Detection and Tracking Using the KLT Algorithm

Questions: 1). After reading some literature, I understood that the output of the KLT tracker should be motion vectors. However, I am only seeing feature points as output.

2). I also wish to plot the trajectories as the object moves. Can someone explain how this can be done please?

Dima
  • 38,860
  • 14
  • 75
  • 115
Sambas23
  • 683
  • 1
  • 13
  • 27

1 Answers1

4

1) The step method of vision.PointTracker returns new locations of the points, instead of the motion vectors. If you need the motion vectors, you can simply subtract the old points from the new points.

2) With each step, the new points are returned in the exact same order as the old points, as long as you do not call setPoints. Let's say you have tracked points for 2 frames:

points1 = step(pointTracker, frame1);
points2 = step(pointTracker, frame2);

Remember, points1 and points2 are M-by-2 matrices of x-y coordinates. So, to plot the trajectory of the i-th point you would do the following:

Xs = [points1(i,1), points2(i,1)];
Ys = [points1(i,2), points2(i,2)];
plot(Xs, Ys, '*-');

By the way, once you get comfortable with this example, check out how to detect and track multiple faces.

Dima
  • 38,860
  • 14
  • 75
  • 115
  • Thank you very much @Dima. Great response. In addition with this I will also wish to ask you this: Sometimes they mention "Harris points" and "minEigenValue points" in order to obtain the best features. Which points are best and which features do Tomasi et al. use in their paper Good Features to track. I understood that "minEigenValue points" are the ones used. Am I right please? – Sambas23 Feb 19 '15 at 16:32
  • @Sambas, yes, min-eigen corners are the "good features to track" from Tomasi and Shi. However, the Harris corners are computed using a very similar algorithm. I don't think you will see much of a difference in accuracy. You can also try the FAST corners using `detectFASTFeatures` function. In the end, you just have to experiment to see what is better and/or faster for your application. – Dima Feb 19 '15 at 16:58
  • By any chance, in case I want to implement the KLT algorithm in MATLAB, do you have any suggested articles or links which you recommend, please? Thanks in advance. – Sambas23 Feb 19 '15 at 18:10
  • Thank you. However that is in C, any MATLAB implementation guide in mind which you recommend? – Sambas23 Feb 19 '15 at 18:24
  • Yes, the implementation is in C. But you can still learn a lot from it. Also, there are links to all the relevant papers on that page. – Dima Feb 19 '15 at 18:25
  • Hi Dima, sorry for bothering you again. But I was trying the procedure on a real footage and the KLT tracker failed very quickly. I posted a new question in this link in case you have some time: http://stackoverflow.com/questions/28623752/klt-tracker-for-human-tracking-in-cctv. Thanks in advance. – Sambas23 Feb 20 '15 at 07:35