Search in sources :

Example 51 with AssociatedPair

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

the class TestGenerateScaleTranslate2D method pathological_noscale.

/**
 * Both points are at 0,0.  Scale can't be resolved
 */
@Test
public void pathological_noscale() {
    ScaleTranslate2D model = new ScaleTranslate2D(1.5, -2, 3);
    AssociatedPair a = TestDistanceScaleTranslate2DSq.apply(0, 0, model);
    AssociatedPair b = TestDistanceScaleTranslate2DSq.apply(0, 0, model);
    List<AssociatedPair> obs = new ArrayList<>();
    obs.add(a);
    obs.add(b);
    ScaleTranslate2D found = new ScaleTranslate2D();
    GenerateScaleTranslate2D alg = new GenerateScaleTranslate2D();
    assertFalse(alg.generate(obs, found));
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ScaleTranslate2D(boofcv.struct.sfm.ScaleTranslate2D) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 52 with AssociatedPair

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

the class TestGenerateScaleTranslate2D method perfect.

@Test
public void perfect() {
    ScaleTranslate2D model = new ScaleTranslate2D(1.5, -2, 3);
    AssociatedPair a = TestDistanceScaleTranslate2DSq.apply(-5, 4, model);
    AssociatedPair b = TestDistanceScaleTranslate2DSq.apply(2, 3, model);
    List<AssociatedPair> obs = new ArrayList<>();
    obs.add(a);
    obs.add(b);
    ScaleTranslate2D found = new ScaleTranslate2D();
    GenerateScaleTranslate2D alg = new GenerateScaleTranslate2D();
    assertTrue(alg.generate(obs, found));
    assertEquals(model.transX, found.transX, 1e-8);
    assertEquals(model.transY, found.transY, 1e-8);
    assertEquals(model.scale, found.scale, 1e-8);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ScaleTranslate2D(boofcv.struct.sfm.ScaleTranslate2D) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 53 with AssociatedPair

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

the class TestGenerateScaleTranslateRotate2D method perfect.

@Test
public void perfect() {
    for (int i = 0; i < 100; i++) {
        double theta = rand.nextDouble() * Math.PI * 2 - Math.PI;
        double scale = rand.nextDouble() * 5 + 0.1;
        ScaleTranslateRotate2D model = new ScaleTranslateRotate2D(theta, scale, -2, 3);
        AssociatedPair a = TestDistanceScaleTranslateRotate2DSq.apply(-5, 4, model);
        AssociatedPair b = TestDistanceScaleTranslateRotate2DSq.apply(2, 3, model);
        AssociatedPair c = TestDistanceScaleTranslateRotate2DSq.apply(-3, 2, model);
        List<AssociatedPair> obs = new ArrayList<>();
        obs.add(a);
        obs.add(b);
        obs.add(c);
        ScaleTranslateRotate2D found = new ScaleTranslateRotate2D();
        GenerateScaleTranslateRotate2D alg = new GenerateScaleTranslateRotate2D();
        assertTrue(alg.generate(obs, found));
        assertEquals(model.transX, found.transX, 1e-8);
        assertEquals(model.transY, found.transY, 1e-8);
        assertEquals(model.scale, found.scale, 1e-8);
        assertEquals(model.theta, found.theta, 1e-8);
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ScaleTranslateRotate2D(boofcv.struct.sfm.ScaleTranslateRotate2D) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 54 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project narchy by automenta.

the class ExampleStereoTwoViewsOneCamera method computeMatches.

/**
 * Use the associate point feature example to create a list of {@link AssociatedPair} for use in computing the
 * fundamental matrix.
 */
public void computeMatches(GrayF32 left, GrayF32 right) {
    DetectDescribePoint detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(1, 2, 0, 1, 9, 4, 4), null, null, GrayF32.class);
    // DetectDescribePoint detDesc = FactoryDetectDescribe.sift(null,new ConfigSiftDetector(2,0,200,5),null,null);
    ScoreAssociation<BrightFeature> scorer = FactoryAssociation.scoreEuclidean(BrightFeature.class, true);
    AssociateDescription<BrightFeature> associate = FactoryAssociation.greedy(scorer, 0.9, true);
    ExampleAssociatePoints<GrayF32, BrightFeature> findMatches = new ExampleAssociatePoints<>(detDesc, associate, GrayF32.class);
    findMatches.associate(left, right);
    FastQueue<AssociatedIndex> matchIndexes = associate.getMatches();
    matchedFeatures.clear();
    for (int i = 0; i < matchIndexes.size; i++) {
        AssociatedIndex a = matchIndexes.get(i);
        matchedFeatures.add(new AssociatedPair(findMatches.pointsA.get(a.src), findMatches.pointsB.get(a.dst)));
    }
}
Also used : DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) AssociatedPair(boofcv.struct.geo.AssociatedPair) BrightFeature(boofcv.struct.feature.BrightFeature) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

Example 55 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project narchy by automenta.

the class ExampleStereoTwoViewsOneCamera method drawInliers.

/**
 * Draw inliers for debugging purposes.  Need to convert from normalized to pixel coordinates.
 */
public void drawInliers(CameraPinholeRadial intrinsic, List<AssociatedPair> normalized) {
    Point2Transform2_F64 n_to_p = LensDistortionOps.narrow(intrinsic).distort_F64(false, true);
    List<AssociatedPair> pixels = new ArrayList<>(normalized.size());
    for (AssociatedPair n : normalized) {
        AssociatedPair p = new AssociatedPair();
        n_to_p.compute(n.p1.x, n.p1.y, p.p1);
        n_to_p.compute(n.p2.x, n.p2.y, p.p2);
        pixels.add(p);
    }
    // display the results
    assocPanel.setAssociation(pixels);
    assocPanel.setImages(ConvertBufferedImage.extractBuffered(distortedPrev), ConvertBufferedImage.extractBuffered(distortedNext));
    assocPanel.repaint();
    assocPanel.setSize(500, 100);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) ArrayList(java.util.ArrayList)

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