There are a few examples of this and and a few methods. If you have complex perspective and background changes, then you need something like this:
Tracking Objects in an Image SequenceLet's apply it to a .GIF file (video sequence is no different) from
this site:
images = Import["http://community.wolfram.com/c/portal/getImageAttachment?filename=freefall.gif&userId=11733"];
Now note how nicely one object is tracked and another isnt because it was not originally in the very 1st frame.
DynamicModule[{res},
res = Table[MapThread[HighlightImage, {images,
ImageFeatureTrack[images, MaxFeatures -> n]}], {n, 5, 50, 5}];
Manipulate[res[[Round[features/5], frame]], {frame, 1, Length[images], 1,
Appearance -> "Labeled"}, {{features, 5}, 5, 50, 5,
Appearance -> "Labeled"}]]
So that used ImageFeatureTrack, but if you have static background and perspective you could write something from scratch (
source):
imgs = Import["http://community.wolfram.com/c/portal/getImageAttachment?filename=dice.gif&userId=11733"];
ListAnimate[Show[ImageCrop[#, {200, 200}], Graphics[{Blue, PointSize[.05],
Point[ComponentMeasurements[MorphologicalComponents[
Dilation[Binarize[ImageCrop[#, {200, 200}]], 1], .3] ,
"Centroid"][[All, 2]]]}], ImageSize -> 300] & /@ imgs]
This free course
Image Processing: Real-World Applicationsshows as one of examples - detection of period of a swinging pendulum from a video record.