Search in sources :

Example 6 with PointTrack

use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.

the class VisOdomDualTrackPnP method estimateMotion.

/**
 * Given the set of active tracks, estimate the cameras motion robustly
 * @return
 */
private boolean estimateMotion() {
    // organize the data
    List<Stereo2D3D> data = new ArrayList<>();
    for (PointTrack l : candidates) {
        LeftTrackInfo info = l.getCookie();
        PointTrack r = info.right;
        Stereo2D3D stereo = info.location;
        // compute normalized image coordinate for track in left and right image
        leftImageToNorm.compute(l.x, l.y, info.location.leftObs);
        rightImageToNorm.compute(r.x, r.y, info.location.rightObs);
        data.add(stereo);
    }
    // Robustly estimate left camera motion
    if (!matcher.process(data))
        return false;
    Se3_F64 keyToCurr = matcher.getModelParameters();
    keyToCurr.invert(currToKey);
    // mark tracks that are in the inlier set
    int N = matcher.getMatchSet().size();
    for (int i = 0; i < N; i++) {
        int index = matcher.getInputIndex(i);
        LeftTrackInfo info = candidates.get(index).getCookie();
        info.lastInlier = tick;
    }
    return true;
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack) Stereo2D3D(boofcv.struct.sfm.Stereo2D3D) ArrayList(java.util.ArrayList) DescribeRegionPoint(boofcv.abst.feature.describe.DescribeRegionPoint) Se3_F64(georegression.struct.se.Se3_F64)

Example 7 with PointTrack

use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.

the class VisOdomMonoPlaneInfinity method changeCurrToReference.

/**
 * Updates the relative position of all points so that the current frame is the reference frame.  Mathematically
 * this is not needed, but should help keep numbers from getting too large.
 */
private void changeCurrToReference() {
    Se2_F64 keyToCurr = currToKey.invert(null);
    List<PointTrack> all = tracker.getAllTracks(null);
    for (PointTrack t : all) {
        VoTrack p = t.getCookie();
        if (p.onPlane) {
            SePointOps_F64.transform(keyToCurr, p.ground, p.ground);
        } else {
            GeometryMath_F64.rotate(keyToCurr.c, keyToCurr.s, p.ground, p.ground);
        }
    }
    concatMotion();
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack) Se2_F64(georegression.struct.se.Se2_F64)

Example 8 with PointTrack

use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.

the class VisOdomPixelDepthPnP method performSecondPass.

private boolean performSecondPass(List<PointTrack> active, List<Point2D3D> obs) {
    Se3_F64 keyToCurr = motionEstimator.getModelParameters();
    Point3D_F64 cameraPt = new Point3D_F64();
    Point2D_F64 predicted = new Point2D_F64();
    // predict where each track should be given the just estimated motion
    List<PointTrack> all = tracker.getAllTracks(null);
    for (PointTrack t : all) {
        Point2D3D p = t.getCookie();
        SePointOps_F64.transform(keyToCurr, p.location, cameraPt);
        normToPixel.compute(cameraPt.x / cameraPt.z, cameraPt.y / cameraPt.z, predicted);
        tracker.setHint(predicted.x, predicted.y, t);
    }
    // redo tracking with the additional information
    tracker.performSecondPass();
    active.clear();
    obs.clear();
    tracker.getActiveTracks(active);
    for (PointTrack t : active) {
        Point2D3D p = t.getCookie();
        pixelToNorm.compute(t.x, t.y, p.observation);
        obs.add(p);
    }
    return motionEstimator.process(obs);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D3D(boofcv.struct.geo.Point2D3D) PointTrack(boofcv.abst.feature.tracker.PointTrack) Point2D_F64(georegression.struct.point.Point2D_F64) Se3_F64(georegression.struct.se.Se3_F64)

Example 9 with PointTrack

use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.

the class VisOdomPixelDepthPnP method changePoseToReference.

/**
 * Updates the relative position of all points so that the current frame is the reference frame.  Mathematically
 * this is not needed, but should help keep numbers from getting too large.
 */
private void changePoseToReference() {
    Se3_F64 keyToCurr = currToKey.invert(null);
    List<PointTrack> all = tracker.getAllTracks(null);
    for (PointTrack t : all) {
        Point2D3DTrack p = t.getCookie();
        SePointOps_F64.transform(keyToCurr, p.location, p.location);
    }
    concatMotion();
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack) Point2D3DTrack(boofcv.struct.sfm.Point2D3DTrack) Se3_F64(georegression.struct.se.Se3_F64)

Example 10 with PointTrack

use of boofcv.abst.feature.tracker.PointTrack in project BoofCV by lessthanoptimal.

the class ExamplePointFeatureTracker method updateGUI.

/**
 * Draw tracked features in blue, or red if they were just spawned.
 */
private void updateGUI(SimpleImageSequence<T> sequence) {
    BufferedImage orig = sequence.getGuiImage();
    Graphics2D g2 = orig.createGraphics();
    // draw tracks with semi-unique colors so you can track individual points with your eyes
    for (PointTrack p : tracker.getActiveTracks(null)) {
        int red = (int) (2.5 * (p.featureId % 100));
        int green = (int) ((255.0 / 150.0) * (p.featureId % 150));
        int blue = (int) (p.featureId % 255);
        VisualizeFeatures.drawPoint(g2, (int) p.x, (int) p.y, new Color(red, green, blue));
    }
    // draw tracks which have just been spawned green
    for (PointTrack p : tracker.getNewTracks(null)) {
        VisualizeFeatures.drawPoint(g2, (int) p.x, (int) p.y, Color.green);
    }
    // tell the GUI to update
    gui.setImage(orig);
    gui.repaint();
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack) BufferedImage(java.awt.image.BufferedImage)

Aggregations

PointTrack (boofcv.abst.feature.tracker.PointTrack)37 Se3_F64 (georegression.struct.se.Se3_F64)9 Point2D3DTrack (boofcv.struct.sfm.Point2D3DTrack)8 ArrayList (java.util.ArrayList)7 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)6 Point2D3D (boofcv.struct.geo.Point2D3D)5 Point3D_F64 (georegression.struct.point.Point3D_F64)5 Stereo2D3D (boofcv.struct.sfm.Stereo2D3D)3 BufferedImage (java.awt.image.BufferedImage)3 Test (org.junit.Test)3 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)2 PkltConfig (boofcv.alg.tracker.klt.PkltConfig)2 ImagePanel (boofcv.gui.image.ImagePanel)2 Webcam (com.github.sarxos.webcam.Webcam)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 AssociatedPairTrack (boofcv.alg.sfm.d2.AssociatedPairTrack)1 VisOdomMonoPlaneInfinity (boofcv.alg.sfm.d3.VisOdomMonoPlaneInfinity)1 ConvertBufferedImage (boofcv.core.image.ConvertBufferedImage)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)1