use of boofcv.alg.tracker.meanshift.TrackerMeanShiftLikelihood 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