Search in sources :

Example 1 with ConfigPKlt

use of boofcv.alg.tracker.klt.ConfigPKlt in project BoofCV by lessthanoptimal.

the class TrackerPointControlPanel method createKltConfig.

static ConfigPKlt createKltConfig() {
    ConfigPKlt klt = new ConfigPKlt();
    klt.pruneClose = true;
    klt.toleranceFB = 4;
    klt.pyramidLevels = ConfigDiscreteLevels.levels(4);
    return klt;
}
Also used : ConfigPKlt(boofcv.alg.tracker.klt.ConfigPKlt)

Example 2 with ConfigPKlt

use of boofcv.alg.tracker.klt.ConfigPKlt in project BoofCV by lessthanoptimal.

the class ExampleTrackingKlt method main.

public static void main(String[] args) {
    // tune the tracker for the image size and visual appearance
    ConfigPointDetector configDetector = new ConfigPointDetector();
    configDetector.type = PointDetectorTypes.SHI_TOMASI;
    configDetector.general.radius = 8;
    configDetector.general.threshold = 1;
    ConfigPKlt configKlt = new ConfigPKlt(3);
    PointTracker<GrayF32> tracker = FactoryPointTracker.klt(configKlt, configDetector, GrayF32.class, null);
    // Open a webcam at a resolution close to 640x480
    Webcam webcam = UtilWebcamCapture.openDefault(640, 480);
    // Create the panel used to display the image and feature tracks
    ImagePanel gui = new ImagePanel();
    gui.setPreferredSize(webcam.getViewSize());
    ShowImages.showWindow(gui, "KLT Tracker", true);
    int minimumTracks = 100;
    while (true) {
        BufferedImage image = webcam.getImage();
        GrayF32 gray = ConvertBufferedImage.convertFrom(image, (GrayF32) null);
        tracker.process(gray);
        List<PointTrack> tracks = tracker.getActiveTracks(null);
        // Spawn tracks if there are too few
        if (tracks.size() < minimumTracks) {
            tracker.spawnTracks();
            tracks = tracker.getActiveTracks(null);
            minimumTracks = tracks.size() / 2;
        }
        // Draw the tracks
        Graphics2D g2 = image.createGraphics();
        for (PointTrack t : tracks) {
            VisualizeFeatures.drawPoint(g2, (int) t.pixel.x, (int) t.pixel.y, Color.RED);
        }
        gui.setImageUI(image);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) PointTrack(boofcv.abst.tracker.PointTrack) Webcam(com.github.sarxos.webcam.Webcam) ConfigPKlt(boofcv.alg.tracker.klt.ConfigPKlt) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) ConfigPointDetector(boofcv.abst.feature.detect.interest.ConfigPointDetector) ImagePanel(boofcv.gui.image.ImagePanel)

Example 3 with ConfigPKlt

use of boofcv.alg.tracker.klt.ConfigPKlt in project BoofCV by lessthanoptimal.

the class TestPointTrackerKltPyramid_MT method createTracker.

@Override
public PointTracker<GrayF32> createTracker() {
    config = new ConfigPKlt();
    // this has been made parallel too
    config.toleranceFB = 2;
    config.maximumTracks.setFixed(0);
    // we want it to always be threaded for stress testing
    config.concurrentMinimumTracks = 0;
    return createKLT(config);
}
Also used : ConfigPKlt(boofcv.alg.tracker.klt.ConfigPKlt)

Example 4 with ConfigPKlt

use of boofcv.alg.tracker.klt.ConfigPKlt in project BoofCV by lessthanoptimal.

the class TestMonoOverhead_to_MonocularPlaneVisualOdometry method createAlgorithm.

protected MonocularPlaneVisualOdometry<GrayU8> createAlgorithm() {
    ConfigPKlt config = new ConfigPKlt();
    config.pyramidLevels = ConfigDiscreteLevels.levels(4);
    config.templateRadius = 3;
    ConfigPointDetector configDetector = new ConfigPointDetector();
    configDetector.type = PointDetectorTypes.SHI_TOMASI;
    configDetector.general.maxFeatures = 600;
    configDetector.general.radius = 3;
    configDetector.general.threshold = 1;
    PointTracker<GrayU8> tracker = FactoryPointTracker.klt(config, configDetector, GrayU8.class, GrayS16.class);
    double cellSize = 0.015;
    double ransacTol = 0.2;
    return FactoryVisualOdometry.monoPlaneOverhead(cellSize, 25, 0.5, ransacTol, 300, 2, 30, 0.5, 0.3, tracker, ImageType.single(GrayU8.class));
}
Also used : ConfigPKlt(boofcv.alg.tracker.klt.ConfigPKlt) GrayU8(boofcv.struct.image.GrayU8) ConfigPointDetector(boofcv.abst.feature.detect.interest.ConfigPointDetector)

Example 5 with ConfigPKlt

use of boofcv.alg.tracker.klt.ConfigPKlt in project BoofCV by lessthanoptimal.

the class VisualizeMonocularPlaneVisualOdometryApp method createVisualOdometry.

private MonocularPlaneVisualOdometry<I> createVisualOdometry(int whichAlg) {
    Class derivType = GImageDerivativeOps.getDerivativeType(imageClass);
    if (whichAlg == 0) {
        var config = new ConfigPlanarTrackPnP();
        config.tracker.typeTracker = ConfigPointTracker.TrackerType.KLT;
        config.tracker.klt.pyramidLevels = ConfigDiscreteLevels.levels(4);
        config.tracker.klt.templateRadius = 3;
        config.tracker.detDesc.detectPoint.type = PointDetectorTypes.SHI_TOMASI;
        config.tracker.detDesc.detectPoint.general.maxFeatures = 600;
        config.tracker.detDesc.detectPoint.general.radius = 3;
        config.tracker.detDesc.detectPoint.general.threshold = 1;
        config.thresholdAdd = 75;
        config.thresholdRetire = 2;
        config.ransac.iterations = 200;
        config.ransac.inlierThreshold = 1.5;
        return FactoryVisualOdometry.monoPlaneInfinity(config, imageClass);
    } else if (whichAlg == 1) {
        ConfigPKlt configKlt = new ConfigPKlt();
        configKlt.pyramidLevels = ConfigDiscreteLevels.levels(4);
        configKlt.templateRadius = 3;
        ConfigPointDetector configDetector = new ConfigPointDetector();
        configDetector.type = PointDetectorTypes.SHI_TOMASI;
        configDetector.general.maxFeatures = 600;
        configDetector.general.radius = 3;
        configDetector.general.threshold = 1;
        PointTracker<I> tracker = FactoryPointTracker.klt(configKlt, configDetector, imageClass, derivType);
        double cellSize = 0.06;
        double inlierGroundTol = 1.5;
        return FactoryVisualOdometry.monoPlaneOverhead(cellSize, 25, 0.7, inlierGroundTol, 300, 2, 100, 0.5, 0.6, tracker, imageType);
    } else {
        throw new RuntimeException("Unknown selection");
    }
}
Also used : ConfigPlanarTrackPnP(boofcv.factory.sfm.ConfigPlanarTrackPnP) ConfigPKlt(boofcv.alg.tracker.klt.ConfigPKlt) ConfigPointTracker(boofcv.factory.tracker.ConfigPointTracker) PointTracker(boofcv.abst.tracker.PointTracker) FactoryPointTracker(boofcv.factory.tracker.FactoryPointTracker) ConfigPointDetector(boofcv.abst.feature.detect.interest.ConfigPointDetector)

Aggregations

ConfigPKlt (boofcv.alg.tracker.klt.ConfigPKlt)6 ConfigPointDetector (boofcv.abst.feature.detect.interest.ConfigPointDetector)3 PointTrack (boofcv.abst.tracker.PointTrack)1 PointTracker (boofcv.abst.tracker.PointTracker)1 ConfigPlanarTrackPnP (boofcv.factory.sfm.ConfigPlanarTrackPnP)1 ConfigPointTracker (boofcv.factory.tracker.ConfigPointTracker)1 FactoryPointTracker (boofcv.factory.tracker.FactoryPointTracker)1 ImagePanel (boofcv.gui.image.ImagePanel)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 GrayF32 (boofcv.struct.image.GrayF32)1 GrayU8 (boofcv.struct.image.GrayU8)1 Webcam (com.github.sarxos.webcam.Webcam)1 BufferedImage (java.awt.image.BufferedImage)1