Search in sources :

Example 21 with PointTrack

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

the class VisOdomDualTrackPnP method mutualTrackDrop.

/**
 * If a track was dropped in one image make sure it was dropped in the other image
 */
private void mutualTrackDrop() {
    for (PointTrack t : trackerLeft.getDroppedTracks(null)) {
        LeftTrackInfo info = t.getCookie();
        trackerRight.dropTrack(info.right);
    }
    for (PointTrack t : trackerRight.getDroppedTracks(null)) {
        RightTrackInfo info = t.getCookie();
        // a track could be dropped twice here, such requests are ignored by the tracker
        trackerLeft.dropTrack(info.left);
    }
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack)

Example 22 with PointTrack

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

the class VisOdomDualTrackPnP method addNewToList.

private void addNewToList(T image, List<PointTrack> tracks, FastQueue<Point2D_F64> points, FastQueue<Desc> descs) {
    describe.setImage(image);
    points.reset();
    descs.reset();
    for (int i = 0; i < tracks.size(); i++) {
        PointTrack t = tracks.get(i);
        // ignoring the return value.  most descriptors never return false and the ones that due will rarely do so
        describe.process(t.x, t.y, 0, 2, descs.grow());
        points.add(t);
    }
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack) DescribeRegionPoint(boofcv.abst.feature.describe.DescribeRegionPoint)

Example 23 with PointTrack

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

the class VisOdomMonoPlaneInfinity method dropUnusedTracks.

/**
 * Removes tracks which have not been included in the inlier set recently
 *
 * @return Number of dropped tracks
 */
private int dropUnusedTracks() {
    List<PointTrack> all = tracker.getAllTracks(null);
    int num = 0;
    for (PointTrack t : all) {
        VoTrack p = t.getCookie();
        if (tick - p.lastInlier > thresholdRetire) {
            tracker.dropTrack(t);
            num++;
        }
    }
    return num;
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack)

Example 24 with PointTrack

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

the class VisOdomMonoPlaneInfinity method sortTracksForEstimation.

/**
 * Splits the set of active tracks into on plane and infinity sets.  For each set also perform specific sanity
 * checks to make sure basic constraints are still being meet.  If not then the track will not be considered for
 * motion estimation.
 */
private void sortTracksForEstimation() {
    // reset data structures
    planeSamples.reset();
    farAngles.reset();
    tracksOnPlane.clear();
    tracksFar.clear();
    // list of active tracks
    List<PointTrack> active = tracker.getActiveTracks(null);
    for (PointTrack t : active) {
        VoTrack p = t.getCookie();
        // compute normalized image coordinate
        pixelToNorm.compute(t.x, t.y, n);
        // rotate pointing vector into plane reference frame
        pointing.set(n.x, n.y, 1);
        GeometryMath_F64.mult(cameraToPlane.getR(), pointing, pointing);
        pointing.normalize();
        if (p.onPlane) {
            // see if it still intersects the plane
            if (pointing.y > 0) {
                // create data structure for robust motion estimation
                PlanePtPixel ppp = planeSamples.grow();
                ppp.normalizedCurr.set(n);
                ppp.planeKey.set(p.ground);
                tracksOnPlane.add(t);
            }
        } else {
            // if the point is not on the plane visually and (optionally) if it passes a strict y-axis rotation
            // test, consider using the point for estimating rotation.
            boolean allGood = pointing.y < 0;
            if (strictFar) {
                allGood = isRotationFromAxisY(t, pointing);
            }
            // is it still above the ground plane and only has motion consistent with rotation on ground plane axis
            if (allGood) {
                computeAngleOfRotation(t, pointing);
                tracksFar.add(t);
            }
        }
    }
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack) PlanePtPixel(boofcv.struct.sfm.PlanePtPixel)

Example 25 with PointTrack

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

the class VisOdomMonoPlaneInfinity method estimateFar.

/**
 * Estimates only rotation using points at infinity.  A robust estimation algorithm is used which finds an angle
 * which maximizes the inlier set, like RANSAC does.  Unlike RANSAC this will produce an optimal result.
 */
private void estimateFar() {
    // do nothing if there are objects at infinity
    farInlierCount = 0;
    if (farAngles.size == 0)
        return;
    farAnglesCopy.reset();
    farAnglesCopy.addAll(farAngles);
    // find angle which maximizes inlier set
    farAngle = maximizeCountInSpread(farAnglesCopy.data, farAngles.size, 2 * thresholdFarAngleError);
    // mark and count inliers
    for (int i = 0; i < tracksFar.size(); i++) {
        PointTrack t = tracksFar.get(i);
        VoTrack p = t.getCookie();
        if (UtilAngle.dist(farAngles.get(i), farAngle) <= thresholdFarAngleError) {
            p.lastInlier = tick;
            farInlierCount++;
        }
    }
}
Also used : PointTrack(boofcv.abst.feature.tracker.PointTrack)

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