use of boofcv.gui.tracker.TrackerObjectQuadPanel in project BoofCV by lessthanoptimal.
the class ExampleTrackerObjectQuad method main.
public static void main(String[] args) {
MediaManager media = DefaultMediaManager.INSTANCE;
String fileName = UtilIO.pathExample("tracking/wildcat_robot.mjpeg");
// Create the tracker. Comment/Uncomment to change the tracker.
TrackerObjectQuad tracker = FactoryTrackerObjectQuad.circulant(null, GrayU8.class);
// FactoryTrackerObjectQuad.sparseFlow(null,GrayU8.class,null);
// FactoryTrackerObjectQuad.tld(null,GrayU8.class);
// FactoryTrackerObjectQuad.meanShiftComaniciu2003(new ConfigComaniciu2003(), ImageType.pl(3, GrayU8.class));
// FactoryTrackerObjectQuad.meanShiftComaniciu2003(new ConfigComaniciu2003(true),ImageType.pl(3,GrayU8.class));
// Mean-shift likelihood will fail in this video, but is excellent at tracking objects with
// a single unique color. See ExampleTrackerMeanShiftLikelihood
// FactoryTrackerObjectQuad.meanShiftLikelihood(30,5,255, MeanShiftLikelihoodType.HISTOGRAM,ImageType.pl(3,GrayU8.class));
SimpleImageSequence video = media.openVideo(fileName, tracker.getImageType());
// specify the target's initial location and initialize with the first frame
Quadrilateral_F64 location = new Quadrilateral_F64(211.0, 162.0, 326.0, 153.0, 335.0, 258.0, 215.0, 249.0);
ImageBase 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.setImageUI((BufferedImage) video.getGuiImage());
gui.setTarget(location, true);
ShowImages.showWindow(gui, "Tracking Results", true);
// Track the object across each video frame and display the results
long previous = 0;
while (video.hasNext()) {
frame = video.next();
boolean visible = tracker.process(frame, location);
gui.setImageUI((BufferedImage) video.getGuiImage());
gui.setTarget(location, visible);
gui.repaint();
// shoot for a specific frame rate
long time = System.currentTimeMillis();
BoofMiscOps.pause(Math.max(0, 80 - (time - previous)));
previous = time;
}
}
use of boofcv.gui.tracker.TrackerObjectQuadPanel in project BoofCV by lessthanoptimal.
the class ExampleTrackerMeanShiftLikelihood method main.
public static void main(String[] args) {
MediaManager media = DefaultMediaManager.INSTANCE;
String fileName = UtilIO.pathExample("tracking/balls_blue_red.mjpeg");
RectangleLength2D_I32 location = new RectangleLength2D_I32(394, 247, 475 - 394, 325 - 247);
ImageType<Planar<GrayU8>> imageType = ImageType.pl(3, GrayU8.class);
SimpleImageSequence<Planar<GrayU8>> video = media.openVideo(fileName, imageType);
// Return a higher likelihood for pixels close to this RGB color
RgbLikelihood likelihood = new RgbLikelihood(64, 71, 69);
TrackerMeanShiftLikelihood<Planar<GrayU8>> tracker = new TrackerMeanShiftLikelihood<>(likelihood, 50, 0.1f);
// specify the target's initial location and initialize with the first frame
Planar<GrayU8> frame = video.next();
// Note that the tracker will not automatically invoke RgbLikelihood.createModel() in its initialize function
tracker.initialize(frame, location);
// For displaying the results
TrackerObjectQuadPanel gui = new TrackerObjectQuadPanel(null);
gui.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight()));
gui.setImageUI((BufferedImage) video.getGuiImage());
gui.setTarget(location, true);
ShowImages.showWindow(gui, "Tracking Results", true);
// Track the object across each video frame and display the results
while (video.hasNext()) {
frame = video.next();
boolean visible = tracker.process(frame);
gui.setImageUI((BufferedImage) video.getGuiImage());
gui.setTarget(tracker.getLocation(), visible);
gui.repaint();
BoofMiscOps.pause(20);
}
}
Aggregations