Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Mathematics
General TopicsResearchOperations ResearchStatisticsMathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Math
Math Software
MapleMathematicaMATLABScilabSASSPSS

Math Forum / Math Software / MATLAB / October 2008



Tip: Looking for answers? Try searching our database.

Video motion tracking algorithms/code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ben Finio - 08 Apr 2008 23:08 GMT
Does anyone know of good code/algorithm for tracking the
coordinates of multiple points in a video file? I work in a
microrobotics lab where we take lots of high-speed video of
very tiny parts. Most of the parts are dark, navy blue or
black, so we can put spots of retroreflective paint at the
points of interest, then use very bright lets to get an
extremely high-contrast video. The algorithm to track ONE
dot is simple enough, just use the threshold function to
convert the grayscale image to black and white, then use the
regionprops function to find the white areas and their
centroids, and track the centroid of the largest area
(assuming your video isn't perfect and there might be some
small white spots that don't get filtered out by threshold).

So how do you extend that to track multiple dots at once? If
you want to track point A and point B (up to an arbitrary
number of points, within reason), you have to somehow make
sure that you are consistent as to which point is which from
frame to frame; i.e., if you start out with point A on the
left and point B on the right, and in the next frame each
point has moved up a tiny bit, odds are that A is still on
the left and B is still on the right, they didn't both jump
all the way across the screen. Using different colors to
track different dots isn't an option since the high-speed
camera only records in grayscale.

Any ideas, suggestions, or links to useful code if it's
already out there would be appreciated.
Ken Campbell - 09 Apr 2008 05:54 GMT
"Ben Finio" <bfinio@fas.harvard.edu> wrote in message
<ftgqc6$7d$1@fred.mathworks.com>...
> Does anyone know of good code/algorithm for tracking the
> coordinates of multiple points in a video file? I work in a
[quoted text clipped - 24 lines]
> Any ideas, suggestions, or links to useful code if it's
> already out there would be appreciated.

This application was quite specific but you might get some
ideas here

http://jap.physiology.org/cgi/content/full/100/4/1311

Ken
MRR - 10 Sep 2008 13:22 GMT
Hi,

I am new in image processing. Right now im searching for developing a program wich was able of tracking a point with a differentiable characteristic (for example, the color), and taking its coordinates.The Kanade-Lucas-Tomasi algorimth could be helpful for what you want to do.

Also, I would like to know if you could help me regarding the tracking of one point, using matlab.

Anyway im researching on it, if i found something I'll let you know.

Kind regards.
Rachita Chandra - 06 Oct 2008 08:21 GMT
Hi Ben,
I am working on exactly the same project right now.I have an image with several points of the same color which are displaced and was trying to figure out a code for tracking the coordinates of multiple points before and after the dispalcement using the correspondingimages.Even I have a black and white image and therefore am not sure how to do this as my image has small points so point A in the first image would eb identified as point B in the second image because of the small displacement.Any suggestion/ideas?I considered centroid tracking but that doesnt seem too efficient.
Also would you have any idea on how to figure out if the image has been merely translated or rotated and not displaced?
I'm using matlab for doing all this.So you think that there would be any better language/software for performing these kind of manipulations?

Thanks a ton for any suggestions!

> Does anyone know of good code/algorithm for tracking the
> coordinates of multiple points in a video file? I work in a
[quoted text clipped - 24 lines]
> Any ideas, suggestions, or links to useful code if it's
> already out there would be appreciated.
MRR - 06 Oct 2008 09:29 GMT
Hi Rachita,

Look at this link:

http://www.ces.clemson.edu/~stb/klt/

Maybe it can be useful for your purpose, because there are the routines implemented for matlab. Also you can see in youtube how Lucas-Kanade algorithm works.

Tracking points from image to image using the called "optical flow" is exactly what Lucas-Kanade do. Also, I have worked with it using OpenCV. With OpenCV comes an example for viewing with lucas-kanade (using a cam or a video stored).

Hope it helps

MRR

> Hi Ben,
> I am working on exactly the same project right now.I have an image with several points of the same color which are displaced and was trying to figure out a code for tracking the coordinates of multiple points before and after the dispalcement using the correspondingimages.Even I have a black and white image and therefore am not sure how to do this as my image has small points so point A in the first image would eb identified as point B in the second image because of the small displacement.Any suggestion/ideas?I considered centroid tracking but that doesnt seem too efficient.
[quoted text clipped - 31 lines]
> > Any ideas, suggestions, or links to useful code if it's
> > already out there would be appreciated.
Rachita Chandra - 14 Oct 2008 12:27 GMT
Hi MRR
Thanks so much for the link,It was useful...I am exploring linking the C code of lucas kanade with matlab somehow cos Im not used to OpenCV...any idea on the matlab subrooutines that were used?

> Hi Rachita,
>
[quoted text clipped - 45 lines]
> > > Any ideas, suggestions, or links to useful code if it's
> > > already out there would be appreciated.
MRR - 14 Oct 2008 23:48 GMT
Hi Rachita,

Im sorry, i used lucas-kanade with Opencv (you have an example in the own libraries). Anyway, in the link i put before i remember it was a guide for the matlab subroutines.

Good luck !!

> Hi MRR
> Thanks so much for the link,It was useful...I am exploring linking the C code of lucas kanade with matlab somehow cos Im not used to OpenCV...any idea on the matlab subrooutines that were used?
[quoted text clipped - 48 lines]
> > > > Any ideas, suggestions, or links to useful code if it's
> > > > already out there would be appreciated.
Ben Finio - 06 Oct 2008 14:44 GMT
Rachita-

I wound up solving the problem with a rather brute-force method (I am a mechanical engineer, not a programmer, so it wasn't very elegant). I have a relatively small number of points (five) that are all about a centimeter apart. The framerate of our camera is high enough that, from frame to frame, each point only moves around a millimeter. So my algorithm is just to calculate the distance from each point in frame i to every other point in frame i+1, then find the minimum of that distance and assign the corresponding points. Of course, if you have a high number of points or they are very close together, this will fail completely. I know there are proper algorithms to do this that I believe other people have posted links to...sorry I can't be of more help.

Also, this isn't really a problem for me at all anymore because my lab recently invested in a 6-camera, $100,000 high-speed motion tracking system from Vicon that does all of this automatically for you. So if you have a few hundred grand laying around then I'd recommend looking into that...otherwise, doing it for free in Matlab is probably a much more economical solution.

> Hi Ben,
> I am working on exactly the same project right now.I have an image with several points of the same color which are displaced and was trying to figure out a code for tracking the coordinates of multiple points before and after the dispalcement using the correspondingimages.Even I have a black and white image and therefore am not sure how to do this as my image has small points so point A in the first image would eb identified as point B in the second image because of the small displacement.Any suggestion/ideas?I considered centroid tracking but that doesnt seem too efficient.
[quoted text clipped - 31 lines]
> > Any ideas, suggestions, or links to useful code if it's
> > already out there would be appreciated.
Rachita Chandra - 14 Oct 2008 11:02 GMT
Hi Ben
Would you know how to check the translation/rotation using matlab(before you got the fancy camera)...I mean how did u decide which pixel to compare the next with, or did you take the area of the body as a whole while comparing two objexts? Was it a clear cut picture or did youhave to threshold the noise out.For instance for a simplistic image on paint in which I have a red ball in the 1st pic and the same ball translated in the 2nd pic.How did your matlab code detect the translation given these two images? Did youwrite a C code or just an ordinary function?
Also for the rotation, did you do a 360 degree check to detect any form of rotation
Thanks for any suggestions on the MATLAB coding.
Regards,
Rachita
Ben Finio - 14 Oct 2008 22:50 GMT
Rachita-

I have a grayscale video image, so first I have to convert that to a binary black and white image, which you can do with the thresh command. You then have to break up the image into foreground and background objects using the bwlabel command:

new_image = bwlabel(old_image,8);

Then I have a bunch of white blobs, each one with its own identifying number in Matlab, on a black background. You use the regionprops command to automatically get the areas and centroids of those blobs:

stuff = regionprops(image_name,'Area','Centroid');

Area will give you the area of each blob in pixels, and Centroid will give you the (x,y) location of the center of each blob, also in pixels. You can deal with noise by finding only the LARGEST blobs based on Area - assuming the points you actually want to track are going to be consistently larger than any unwanted noisy points.

I am not totally clear as to what you're asking about rotation. I have a physical shape (I'm tracking a wing) and I apply the white markers at known locations on the wing. So, if I know the orientation of the camera, I can extract the 3D position of the wing just using a 2D image simply by using geometry/trigonometry.

> Hi Ben
> Would you know how to check the translation/rotation using matlab(before you got the fancy camera)...I mean how did u decide which pixel to compare the next with, or did you take the area of the body as a whole while comparing two objexts? Was it a clear cut picture or did youhave to threshold the noise out.For instance for a simplistic image on paint in which I have a red ball in the 1st pic and the same ball translated in the 2nd pic.How did your matlab code detect the translation given these two images? Did youwrite a C code or just an ordinary function?
> Also for the rotation, did you do a 360 degree check to detect any form of rotation
> Thanks for any suggestions on the MATLAB coding.
> Regards,
> Rachita
Rachita Chandra - 31 Oct 2008 10:54 GMT
Did your code/algorithm end up working? I mean did it succeed in detecting the blobs and tracking them successfully and returning the location before and after?

> Rachita-
>
[quoted text clipped - 16 lines]
> > Regards,
> > Rachita
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.