Search in sources :

Example 6 with ScaleTranslate2D

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

the class TestModelManagerScaleTranslate2D method copyModel.

@Test
public void copyModel() {
    ModelManagerScaleTranslate2D alg = new ModelManagerScaleTranslate2D();
    ScaleTranslate2D model = new ScaleTranslate2D(1, 2, 3);
    ScaleTranslate2D found = new ScaleTranslate2D();
    alg.copyModel(model, found);
    assertEquals(model.scale, found.scale, 1e-8);
    assertEquals(model.transX, found.transX, 1e-8);
    assertEquals(model.transY, found.transY, 1e-8);
}
Also used : ScaleTranslate2D(boofcv.struct.sfm.ScaleTranslate2D) Test(org.junit.Test)

Example 7 with ScaleTranslate2D

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

the class TestTldAdjustRegion method adjustRectangle.

@Test
public void adjustRectangle() {
    TldAdjustRegion alg = new TldAdjustRegion(50);
    Rectangle2D_F64 rect = new Rectangle2D_F64(10, 20, 30, 40);
    ScaleTranslate2D motion = new ScaleTranslate2D(1.5, 2, 3);
    alg.adjustRectangle(rect, motion);
    assertEquals(17, rect.p0.x, 1e-8);
    assertEquals(33, rect.p0.y, 1e-8);
    assertEquals(47, rect.p1.x, 1e-8);
    assertEquals(63, rect.p1.y, 1e-8);
}
Also used : Rectangle2D_F64(georegression.struct.shapes.Rectangle2D_F64) ScaleTranslate2D(boofcv.struct.sfm.ScaleTranslate2D) Test(org.junit.Test)

Example 8 with ScaleTranslate2D

use of boofcv.struct.sfm.ScaleTranslate2D 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 9 with ScaleTranslate2D

use of boofcv.struct.sfm.ScaleTranslate2D 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)

Example 10 with ScaleTranslate2D

use of boofcv.struct.sfm.ScaleTranslate2D 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)

Aggregations

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