Search in sources :

Example 91 with AssociatedPair

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

the class TestDistanceScaleTranslateRotate2DSq method apply.

public static AssociatedPair apply(double x, double y, ScaleTranslateRotate2D model) {
    AssociatedPair p = new AssociatedPair();
    p.p1.set(x, y);
    double c = Math.cos(model.theta);
    double s = Math.sin(model.theta);
    p.p2.x = (x * c - y * s) * model.scale + model.transX;
    p.p2.y = (x * s + y * c) * model.scale + model.transY;
    return p;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair)

Example 92 with AssociatedPair

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

the class TestDistanceScaleTranslateRotate2DSq method perfect.

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

Example 93 with AssociatedPair

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

the class TestDistanceScaleTranslateRotate2DSq method multiple.

@Test
public void multiple() {
    ScaleTranslateRotate2D model = new ScaleTranslateRotate2D(0.2, 1.5, -2, 3);
    AssociatedPair a = apply(-5, 4, model);
    a.p2.x += 3.5;
    AssociatedPair b = apply(2.15, 2, model);
    List<AssociatedPair> obs = new ArrayList<>();
    obs.add(a);
    obs.add(b);
    DistanceScaleTranslateRotate2DSq alg = new DistanceScaleTranslateRotate2DSq();
    alg.setModel(model);
    double[] found = new double[2];
    alg.computeDistance(obs, found);
    assertEquals(3.5 * 3.5, found[0], 1e-8);
    assertEquals(0, found[1], 1e-8);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ScaleTranslateRotate2D(boofcv.struct.sfm.ScaleTranslateRotate2D) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 94 with AssociatedPair

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

the class TestGenerateScaleTranslate2D method onePointAtZero_a.

/**
 * Possible pathological case.  One point is at zero.
 */
@Test
public void onePointAtZero_a() {
    ScaleTranslate2D model = new ScaleTranslate2D(1.5, -2, 3);
    AssociatedPair a = TestDistanceScaleTranslate2DSq.apply(0, 0, 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 95 with AssociatedPair

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

the class TestGenerateSe2_AssociatedPair method createRandomPointFromModel.

@Override
public AssociatedPair createRandomPointFromModel(Se2_F64 motion) {
    Point2D_F64 location = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
    Point2D_F64 observation = new Point2D_F64();
    SePointOps_F64.transform(motion, location, observation);
    return new AssociatedPair(location, observation);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) GenerateSe2_AssociatedPair(boofcv.alg.geo.robust.GenerateSe2_AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64)

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