Search in sources :

Example 1 with ScaleTranslate2D

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

the class TestDistanceScaleTranslate2DSq method noisy.

@Test
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.distance(a), 1e-8);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ScaleTranslate2D(boofcv.struct.geo.ScaleTranslate2D) Test(org.junit.jupiter.api.Test)

Example 2 with ScaleTranslate2D

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

the class TestDistanceScaleTranslate2DSq method multiple.

@Test
void multiple() {
    ScaleTranslate2D model = new ScaleTranslate2D(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);
    DistanceScaleTranslate2DSq alg = new DistanceScaleTranslate2DSq();
    alg.setModel(model);
    double[] found = new double[2];
    alg.distances(obs, found);
    assertEquals(3.5 * 3.5, found[0], 1e-8);
    assertEquals(0, found[1], 1e-8);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ScaleTranslate2D(boofcv.struct.geo.ScaleTranslate2D) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 3 with ScaleTranslate2D

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

the class TestDistanceScaleTranslate2DSq method perfect.

@Test
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.distance(a), 1e-8);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ScaleTranslate2D(boofcv.struct.geo.ScaleTranslate2D) Test(org.junit.jupiter.api.Test)

Example 4 with ScaleTranslate2D

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

the class TestGenerateScaleTranslate2D method onePointAtZero_a.

/**
 * Possible pathological case. One point is at zero.
 */
@Test
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.geo.ScaleTranslate2D) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 5 with ScaleTranslate2D

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

the class TestGenerateScaleTranslate2D method pathological_noscale.

/**
 * Both points are at 0,0. Scale can't be resolved
 */
@Test
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.geo.ScaleTranslate2D) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

ScaleTranslate2D (boofcv.struct.geo.ScaleTranslate2D)10 Test (org.junit.jupiter.api.Test)9 AssociatedPair (boofcv.struct.geo.AssociatedPair)7 ArrayList (java.util.ArrayList)4 Rectangle2D_F64 (georegression.struct.shapes.Rectangle2D_F64)2 GenerateScaleTranslate2D (boofcv.alg.geo.robust.GenerateScaleTranslate2D)1 ModelManagerScaleTranslate2D (boofcv.alg.geo.robust.ModelManagerScaleTranslate2D)1 DogArray (org.ddogleg.struct.DogArray)1