use of org.ddogleg.optimization.UnconstrainedLeastSquares in project BoofCV by lessthanoptimal.
the class TestTrifocalAlgebraicPoint7 method noisy.
/**
* Give it noisy inputs and see if it produces a better solution than the non-iterative algorithm.
*/
@Test
public void noisy() {
List<AssociatedTriple> noisyObs = new ArrayList<>();
// create a noisy set of observations
double noiseLevel = 0.25;
for (AssociatedTriple p : observations) {
AssociatedTriple n = p.copy();
n.p1.x += rand.nextGaussian() * noiseLevel;
n.p1.y += rand.nextGaussian() * noiseLevel;
n.p2.x += rand.nextGaussian() * noiseLevel;
n.p2.y += rand.nextGaussian() * noiseLevel;
n.p3.x += rand.nextGaussian() * noiseLevel;
n.p3.y += rand.nextGaussian() * noiseLevel;
noisyObs.add(n);
}
UnconstrainedLeastSquares optimizer = FactoryOptimization.leastSquareLevenberg(1e-3);
TrifocalAlgebraicPoint7 alg = new TrifocalAlgebraicPoint7(optimizer, 300, 1e-20, 1e-20);
assertTrue(alg.process(noisyObs, found));
found.normalizeScale();
// only the induced error is tested since the constraint error has unknown units and is quite large
checkInducedErrors(found, noisyObs, 2);
}
use of org.ddogleg.optimization.UnconstrainedLeastSquares in project BoofCV by lessthanoptimal.
the class TestTrifocalAlgebraicPoint7 method noisy.
private void noisy(boolean planar) {
createSceneObservations(planar);
List<AssociatedTriple> noisyObs = new ArrayList<>();
// create a noisy set of observations
double noiseLevel = 0.5;
for (AssociatedTriple p : observationsPixels) {
AssociatedTriple n = p.copy();
n.p1.x += rand.nextGaussian() * noiseLevel;
n.p1.y += rand.nextGaussian() * noiseLevel;
n.p2.x += rand.nextGaussian() * noiseLevel;
n.p2.y += rand.nextGaussian() * noiseLevel;
n.p3.x += rand.nextGaussian() * noiseLevel;
n.p3.y += rand.nextGaussian() * noiseLevel;
noisyObs.add(n);
}
TrifocalLinearPoint7 linear = new TrifocalLinearPoint7();
linear.process(noisyObs, found);
double errorLinear = computeTransferError(found, noisyObs);
UnconstrainedLeastSquares optimizer = FactoryOptimization.levenbergMarquardt(null, true);
TrifocalAlgebraicPoint7 alg = new TrifocalAlgebraicPoint7(optimizer, 300, 1e-20, 1e-20);
assertTrue(alg.process(noisyObs, found));
// only the induced error is tested since the constraint error has unknown units and is quite large
double errorsAlg = computeTransferError(found, noisyObs);
// it appears that the linear estimate is very accurate. This is a really a test to see if it made
// the solution significantly worse
assertTrue(errorsAlg <= errorLinear * 1.2);
}
use of org.ddogleg.optimization.UnconstrainedLeastSquares in project BoofCV by lessthanoptimal.
the class FactoryMultiView method estimateTrifocal_1.
/**
* Creates a trifocal tensor estimation algorithm.
*
* @param type Which algorithm.
* @param iterations If the algorithm is iterative, then this is the number of iterations. Try 200
* @return Trifocal tensor estimator
*/
public static Estimate1ofTrifocalTensor estimateTrifocal_1(EnumTrifocal type, int iterations) {
switch(type) {
case LINEAR_7:
return new WrapTrifocalLinearPoint7();
case ALGEBRAIC_7:
UnconstrainedLeastSquares optimizer = FactoryOptimization.leastSquaresLM(1e-3, false);
TrifocalAlgebraicPoint7 alg = new TrifocalAlgebraicPoint7(optimizer, iterations, 1e-12, 1e-12);
return new WrapTrifocalAlgebraicPoint7(alg);
}
throw new IllegalArgumentException("Unknown type " + type);
}
use of org.ddogleg.optimization.UnconstrainedLeastSquares in project BoofCV by lessthanoptimal.
the class TestTrifocalAlgebraicPoint7 method perfect.
/**
* Give it perfect inputs and make sure it doesn't screw things up
*/
@Test
public void perfect() {
UnconstrainedLeastSquares optimizer = FactoryOptimization.leastSquareLevenberg(1e-3);
TrifocalAlgebraicPoint7 alg = new TrifocalAlgebraicPoint7(optimizer, 300, 1e-20, 1e-20);
assertTrue(alg.process(observations, found));
checkTrifocalWithConstraint(found, 1e-8);
checkInducedErrors(found, observations, 1e-8);
}
use of org.ddogleg.optimization.UnconstrainedLeastSquares in project BoofCV by lessthanoptimal.
the class TestTrifocalAlgebraicPoint7 method perfect.
private void perfect(boolean planar) {
createSceneObservations(planar);
UnconstrainedLeastSquares optimizer = FactoryOptimization.levenbergMarquardt(null, false);
TrifocalAlgebraicPoint7 alg = new TrifocalAlgebraicPoint7(optimizer, 300, 1e-20, 1e-20);
assertTrue(alg.process(observations, found));
checkTrifocalWithConstraint(found, 5e-7);
assertEquals(0, computeTransferError(found, observations), UtilEjml.TEST_F64);
}
Aggregations