Difference between revisions of "Example Tracker Object"
From BoofCV
Jump to navigationJump to search (Created page with "<center> <gallery widths=400px heights=300px> file:Example_tracking_object.jpg | Last frame from a sequence where the book was tracked using the ciruclant tracker. </gallery> ...") |
m |
||
Line 8: | Line 8: | ||
Example Code: | Example Code: | ||
* [https://github.com/lessthanoptimal/BoofCV/blob/v0. | * [https://github.com/lessthanoptimal/BoofCV/blob/v0.17/examples/src/boofcv/examples/tracking/ExampleTrackerObjectQuad.java ExampleTrackerObjectQuad.java] | ||
Concepts: | Concepts: | ||
Line 44: | Line 44: | ||
// from the list since they use color information and including color images could clutter up the example. | // from the list since they use color information and including color images could clutter up the example. | ||
TrackerObjectQuad<ImageUInt8> tracker = | TrackerObjectQuad<ImageUInt8> tracker = | ||
FactoryTrackerObjectQuad.circulant( | FactoryTrackerObjectQuad.circulant(null, ImageUInt8.class); | ||
// FactoryTrackerObjectQuad.sparseFlow( | // FactoryTrackerObjectQuad.sparseFlow(null,ImageUInt8.class,null); | ||
// FactoryTrackerObjectQuad.tld( | // FactoryTrackerObjectQuad.tld(null,ImageUInt8.class); | ||
// specify the target's initial location and initialize with the first frame | // specify the target's initial location and initialize with the first frame |
Revision as of 13:15, 19 June 2014
In this example several different trackers can be used to track the object in the video. All of the trackers in this example use texture information (see mean-shift example for color based trackers) to localize and track the object. No one single tracker can track all the video sequences provided with BoofCV or in general. You should try out all the different video sequences and see which trackers work best when.
Example Code:
Concepts:
- Object tracking
- Local trackers
- Re-detection
Relevant Applets:
Example Code
/**
* Demonstration on how to use the high level {@link TrackerObjectQuad} interface for tracking objects in a
* video sequence. This interface allows the target to be specified using an arbitrary quadrilateral. Specific
* implementations might not support that shape, so they instead will track an approximation of it. The
* interface also allows information on target visibility to be returned. As is usually the case, tracker
* specific information is lost in the high level interface and you should consider using the trackers
* directly if more control is needed.
*
* This is an active area of research and all of the trackers eventually diverge given a long enough sequence.
*
* @author Peter Abeles
*/
public class ExampleTrackerObjectQuad {
public static void main(String[] args) {
MediaManager media = DefaultMediaManager.INSTANCE;
String fileName = "../data/applet/tracking/track_book.mjpeg";
SimpleImageSequence<ImageUInt8> video = media.openVideo(fileName, ImageType.single(ImageUInt8.class));
// Create the tracker. Comment/Uncomment to change the tracker. Mean-shift trackers have been omitted
// from the list since they use color information and including color images could clutter up the example.
TrackerObjectQuad<ImageUInt8> tracker =
FactoryTrackerObjectQuad.circulant(null, ImageUInt8.class);
// FactoryTrackerObjectQuad.sparseFlow(null,ImageUInt8.class,null);
// FactoryTrackerObjectQuad.tld(null,ImageUInt8.class);
// specify the target's initial location and initialize with the first frame
Quadrilateral_F64 location = new Quadrilateral_F64(276,159,362,163,358,292,273,289);
ImageUInt8 frame = video.next();
tracker.initialize(frame,location);
// For displaying the results
TrackerObjectQuadPanel gui = new TrackerObjectQuadPanel(null);
gui.setPreferredSize(new Dimension(frame.getWidth(),frame.getHeight()));
gui.setBackGround((BufferedImage)video.getGuiImage());
gui.setTarget(location,true);
ShowImages.showWindow(gui,"Tracking Results");
// Track the object across each video frame and display the results
while( video.hasNext() ) {
frame = video.next();
boolean visible = tracker.process(frame,location);
gui.setBackGround((BufferedImage) video.getGuiImage());
gui.setTarget(location,visible);
gui.repaint();
BoofMiscOps.pause(20);
}
}
}