Search in sources :

Example 86 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.

the class TldRegionTracker method trackFeature.

/**
 * Tracks KLT features in forward/reverse direction and the tracking error metrics
 */
protected boolean trackFeature() {
    pairs.reset();
    // total number of tracks which contribute to FB error
    int numTracksFB = 0;
    // tracks which are not dropped
    int numTracksRemaining = 0;
    for (int i = 0; i < tracks.length; i++) {
        Track t = tracks[i];
        if (!t.active)
            continue;
        float prevX = t.klt.x;
        float prevY = t.klt.y;
        // track in forwards direction
        tracker.setImage(currentImage, currentDerivX, currentDerivY);
        KltTrackFault result = tracker.track(t.klt);
        if (result != KltTrackFault.SUCCESS) {
            t.active = false;
            continue;
        }
        float currX = t.klt.x;
        float currY = t.klt.y;
        // track in reverse direction
        tracker.setDescription(t.klt);
        tracker.setImage(previousImage, previousDerivX, previousDerivY);
        result = tracker.track(t.klt);
        if (result != KltTrackFault.SUCCESS) {
            t.active = false;
            continue;
        }
        // compute forward-backwards error
        double errorForwardBackwards = UtilPoint2D_F32.distanceSq(prevX, prevY, t.klt.x, t.klt.y);
        // put into lists for computing the median error
        errorsFB[numTracksFB++] = errorForwardBackwards;
        // discard if error is too large
        if (errorForwardBackwards > maxErrorFB) {
            t.active = false;
            continue;
        }
        // create data structure used for group motion estimation
        AssociatedPair p = pairs.grow();
        p.p1.set(prevX, prevY);
        p.p2.set(currX, currY);
        numTracksRemaining++;
    }
    // if the forward-backwards error is too large, give up
    double medianFB = QuickSelect.select(errorsFB, numTracksFB / 2, numTracksFB);
    if (medianFB > maxErrorFB || numTracksRemaining < 4)
        return false;
    return true;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) KltTrackFault(boofcv.alg.tracker.klt.KltTrackFault)

Example 87 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.

the class QrCodeBinaryGridToPixel method set.

private void set(float row, float col, Polygon2D_F64 polygon, int corner) {
    AssociatedPair p = storagePairs.grow();
    Point2D_F64 c = polygon.get(corner);
    p.set(c.x, c.y, col, row);
    pairs.add(p);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64)

Example 88 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.

the class QrCodeBinaryGridToPixel method removeFeatureWithLargestError.

public boolean removeFeatureWithLargestError() {
    int selected = -1;
    double largestError = 0;
    for (int i = 0; i < pairs.size(); i++) {
        AssociatedPair p = pairs.get(i);
        HomographyPointOps_F64.transform(Hinv, p.p2.x, p.p2.y, tmp64);
        double dx = tmp64.x - p.p1.x;
        double dy = tmp64.y - p.p1.y;
        double error = dx * dx + dy * dy;
        if (error > largestError) {
            largestError = error;
            selected = i;
        }
    }
    if (selected != -1 && largestError > 2 * 2) {
        pairs.remove(selected);
        return true;
    } else {
        return false;
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair)

Example 89 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.

the class TestDistanceScaleTranslate2DSq method perfect.

@Test
public void perfect() {
    ScaleTranslate2D model = new ScaleTranslate2D(1.5, -2, 3);
    AssociatedPair a = apply(-5, 4, model);
    DistanceScaleTranslate2DSq alg = new DistanceScaleTranslate2DSq();
    alg.setModel(model);
    assertEquals(0, alg.computeDistance(a), 1e-8);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ScaleTranslate2D(boofcv.struct.sfm.ScaleTranslate2D) Test(org.junit.Test)

Example 90 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.

the class TestDistanceScaleTranslate2DSq method noisy.

@Test
public void noisy() {
    ScaleTranslate2D model = new ScaleTranslate2D(1.5, -2, 3);
    AssociatedPair a = apply(-5, 4, model);
    a.p2.x += 3.5;
    DistanceScaleTranslate2DSq alg = new DistanceScaleTranslate2DSq();
    alg.setModel(model);
    assertEquals(3.5 * 3.5, alg.computeDistance(a), 1e-8);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ScaleTranslate2D(boofcv.struct.sfm.ScaleTranslate2D) Test(org.junit.Test)

Aggregations

AssociatedPair (boofcv.struct.geo.AssociatedPair)110 Test (org.junit.Test)32 Point2D_F64 (georegression.struct.point.Point2D_F64)28 ArrayList (java.util.ArrayList)27 DMatrixRMaj (org.ejml.data.DMatrixRMaj)22 Se3_F64 (georegression.struct.se.Se3_F64)17 Point3D_F64 (georegression.struct.point.Point3D_F64)12 ScaleTranslate2D (boofcv.struct.sfm.ScaleTranslate2D)7 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)6 Estimate1ofEpipolar (boofcv.abst.geo.Estimate1ofEpipolar)5 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)4 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)4 ScaleTranslateRotate2D (boofcv.struct.sfm.ScaleTranslateRotate2D)4 ClosestPoint3D_F64 (georegression.metric.ClosestPoint3D_F64)4 ConfigFastHessian (boofcv.abst.feature.detect.interest.ConfigFastHessian)3 TriangulateTwoViewsCalibrated (boofcv.abst.geo.TriangulateTwoViewsCalibrated)3 AssociationPanel (boofcv.gui.feature.AssociationPanel)3 BrightFeature (boofcv.struct.feature.BrightFeature)3 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)3 Ransac (org.ddogleg.fitting.modelset.ransac.Ransac)3