Search in sources :

Example 1 with TrackerObjectQuad

use of boofcv.abst.tracker.TrackerObjectQuad 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;
    }
}
Also used : SimpleImageSequence(boofcv.io.image.SimpleImageSequence) Quadrilateral_F64(georegression.struct.shapes.Quadrilateral_F64) MediaManager(boofcv.io.MediaManager) DefaultMediaManager(boofcv.io.wrapper.DefaultMediaManager) FactoryTrackerObjectQuad(boofcv.factory.tracker.FactoryTrackerObjectQuad) TrackerObjectQuad(boofcv.abst.tracker.TrackerObjectQuad) TrackerObjectQuadPanel(boofcv.gui.tracker.TrackerObjectQuadPanel) ImageBase(boofcv.struct.image.ImageBase)

Example 2 with TrackerObjectQuad

use of boofcv.abst.tracker.TrackerObjectQuad in project BoofCV by lessthanoptimal.

the class ExampleWebcamObjectTracking method main.

public static void main(String[] args) {
    ImageType<Planar<GrayU8>> colorType = ImageType.pl(3, GrayU8.class);
    TrackerObjectQuad tracker = FactoryTrackerObjectQuad.circulant(null, GrayU8.class);
    // FactoryTrackerObjectQuad.sparseFlow(null,GrayU8.class,null);
    // FactoryTrackerObjectQuad.tld(null,GrayU8.class);
    // FactoryTrackerObjectQuad.meanShiftComaniciu2003(new ConfigComaniciu2003(), colorType);
    // FactoryTrackerObjectQuad.meanShiftComaniciu2003(new ConfigComaniciu2003(true),colorType);
    // FactoryTrackerObjectQuad.meanShiftLikelihood(30,5,255, MeanShiftLikelihoodType.HISTOGRAM,colorType);
    ExampleWebcamObjectTracking app = new ExampleWebcamObjectTracking(tracker, 640, 480);
    app.process();
}
Also used : Planar(boofcv.struct.image.Planar) FactoryTrackerObjectQuad(boofcv.factory.tracker.FactoryTrackerObjectQuad) TrackerObjectQuad(boofcv.abst.tracker.TrackerObjectQuad)

Example 3 with TrackerObjectQuad

use of boofcv.abst.tracker.TrackerObjectQuad in project narchy by automenta.

the class WebcamObjectTrack method main.

public static void main(String[] args) {
    ImageType<MultiSpectral<ImageUInt8>> colorType = ImageType.ms(3, ImageUInt8.class);
    TrackerObjectQuad tracker = FactoryTrackerObjectQuad.circulant(null, ImageUInt8.class);
    // FactoryTrackerObjectQuad.sparseFlow(null,ImageUInt8.class,null);
    // FactoryTrackerObjectQuad.tld(null,ImageUInt8.class);
    // FactoryTrackerObjectQuad.meanShiftComaniciu2003(new ConfigComaniciu2003(), colorType);
    // FactoryTrackerObjectQuad.meanShiftComaniciu2003(new ConfigComaniciu2003(true),colorType);
    // FactoryTrackerObjectQuad.meanShiftLikelihood(30,5,255, MeanShiftLikelihoodType.HISTOGRAM,colorType);
    WebcamObjectTrack app = new WebcamObjectTrack(tracker, 640, 480);
    app.process();
}
Also used : FactoryTrackerObjectQuad(boofcv.factory.tracker.FactoryTrackerObjectQuad) TrackerObjectQuad(boofcv.abst.tracker.TrackerObjectQuad)

Aggregations

TrackerObjectQuad (boofcv.abst.tracker.TrackerObjectQuad)3 FactoryTrackerObjectQuad (boofcv.factory.tracker.FactoryTrackerObjectQuad)3 TrackerObjectQuadPanel (boofcv.gui.tracker.TrackerObjectQuadPanel)1 MediaManager (boofcv.io.MediaManager)1 SimpleImageSequence (boofcv.io.image.SimpleImageSequence)1 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)1 ImageBase (boofcv.struct.image.ImageBase)1 Planar (boofcv.struct.image.Planar)1 Quadrilateral_F64 (georegression.struct.shapes.Quadrilateral_F64)1