Search in sources :

Example 21 with SceneObservations

use of boofcv.abst.geo.bundle.SceneObservations in project BoofCV by lessthanoptimal.

the class TestBundleAdjustmentProjectiveResidualFunction method multipleCalls.

void multipleCalls(boolean homogenous) {
    SceneStructureProjective structure = homogenous ? createSceneH(rand) : createScene3D(rand);
    SceneObservations obs = createObservations(rand, structure);
    double[] param = new double[structure.getParameterCount()];
    new CodecSceneStructureProjective().encode(structure, param);
    BundleAdjustmentProjectiveResidualFunction alg = new BundleAdjustmentProjectiveResidualFunction();
    alg.configure(structure, obs);
    double[] expected = new double[alg.getNumOfOutputsM()];
    double[] found = new double[alg.getNumOfOutputsM()];
    alg.process(param, expected);
    alg.process(param, found);
    assertArrayEquals(expected, found, UtilEjml.TEST_F64);
}
Also used : SceneStructureProjective(boofcv.abst.geo.bundle.SceneStructureProjective) SceneObservations(boofcv.abst.geo.bundle.SceneObservations)

Example 22 with SceneObservations

use of boofcv.abst.geo.bundle.SceneObservations in project BoofCV by lessthanoptimal.

the class TestBundleAdjustmentProjectiveSchurJacobian_DSCC method compareToNumerical_Homogenous.

@Test
void compareToNumerical_Homogenous() {
    SceneStructureProjective structure = createSceneH(rand);
    SceneObservations observations = createObservations(rand, structure);
    double[] param = new double[structure.getParameterCount()];
    new CodecSceneStructureProjective().encode(structure, param);
    BundleAdjustmentProjectiveSchurJacobian_DSCC alg = new BundleAdjustmentProjectiveSchurJacobian_DSCC();
    FunctionNtoMxN<DMatrixSparseCSC> jac = new SchurJacobian_to_NtoMxN.DSCC(alg);
    BundleAdjustmentProjectiveResidualFunction func = new BundleAdjustmentProjectiveResidualFunction();
    alg.configure(structure, observations);
    func.configure(structure, observations);
    // DerivativeChecker.jacobianPrint(func, jac, param, 0.1 );
    assertTrue(DerivativeChecker.jacobian(func, jac, param, 0.1));
}
Also used : SceneStructureProjective(boofcv.abst.geo.bundle.SceneStructureProjective) SceneObservations(boofcv.abst.geo.bundle.SceneObservations) DMatrixSparseCSC(org.ejml.data.DMatrixSparseCSC) Test(org.junit.jupiter.api.Test)

Example 23 with SceneObservations

use of boofcv.abst.geo.bundle.SceneObservations in project BoofCV by lessthanoptimal.

the class CommonBundleAdjustmentMetricSchurJacobian method compareToNumerical_relative.

public void compareToNumerical_relative(boolean homogenous) {
    SceneStructureMetric structure = createScene(rand, homogenous, false, true);
    SceneObservations observations = createObservations(rand, structure);
    // Try different patterns of relative views and attempt to cover all the edge cases
    compareToNumerical_relative(new boolean[] { true, true, true, false }, structure, observations);
    compareToNumerical_relative(new boolean[] { true, true, false, true }, structure, observations);
    compareToNumerical_relative(new boolean[] { true, true, false, false }, structure, observations);
    compareToNumerical_relative(new boolean[] { true, false, false, false }, structure, observations);
    compareToNumerical_relative(new boolean[] { true, false, true, false }, structure, observations);
    compareToNumerical_relative(new boolean[] { false, true, true, true }, structure, observations);
}
Also used : SceneStructureMetric(boofcv.abst.geo.bundle.SceneStructureMetric) SceneObservations(boofcv.abst.geo.bundle.SceneObservations)

Example 24 with SceneObservations

use of boofcv.abst.geo.bundle.SceneObservations in project BoofCV by lessthanoptimal.

the class CommonBundleAdjustmentMetricSchurJacobian method compareToNumerical.

public void compareToNumerical(BundleAdjustmentMetricSchurJacobian<M> alg, boolean homogenous, boolean hasRigid, boolean hasRelative) {
    SceneStructureMetric structure = createScene(rand, homogenous, hasRigid, hasRelative);
    SceneObservations observations = createObservations(rand, structure);
    var param = new double[structure.getParameterCount()];
    new CodecSceneStructureMetric().encode(structure, param);
    var jac = createJacobian(alg);
    var func = new BundleAdjustmentMetricResidualFunction();
    alg.configure(structure, observations);
    func.configure(structure, observations);
    // TODO I think the Rodrigues jacobian is computed in a numerically unstable way.
    // multiplying tolerance by 100 is ridiculous
    // DerivativeChecker.jacobianPrint(func, jac, param, 100*UtilEjml.TEST_F64_SQ );
    assertTrue(DerivativeChecker.jacobian(func, jac, param, 110 * UtilEjml.TEST_F64_SQ));
}
Also used : SceneStructureMetric(boofcv.abst.geo.bundle.SceneStructureMetric) SceneObservations(boofcv.abst.geo.bundle.SceneObservations)

Example 25 with SceneObservations

use of boofcv.abst.geo.bundle.SceneObservations in project BoofCV by lessthanoptimal.

the class CommonBundleAdjustmentMetricSchurJacobian method sameMotionInChain.

public void sameMotionInChain(boolean homogenous) {
    SceneStructureMetric structure = createSceneChainSameMotion(rand, homogenous);
    SceneObservations observations = createObservations(rand, structure);
    var param = new double[structure.getParameterCount()];
    new CodecSceneStructureMetric().encode(structure, param);
    var alg = createAlg();
    var jac = createJacobian(alg);
    var func = new BundleAdjustmentMetricResidualFunction();
    alg.configure(structure, observations);
    func.configure(structure, observations);
    // DerivativeChecker.jacobianPrint(func, jac, param, 100*UtilEjml.TEST_F64_SQ );
    assertTrue(DerivativeChecker.jacobian(func, jac, param, 100 * UtilEjml.TEST_F64_SQ));
}
Also used : SceneStructureMetric(boofcv.abst.geo.bundle.SceneStructureMetric) SceneObservations(boofcv.abst.geo.bundle.SceneObservations)

Aggregations

SceneObservations (boofcv.abst.geo.bundle.SceneObservations)32 SceneStructureMetric (boofcv.abst.geo.bundle.SceneStructureMetric)21 VerbosePrint (org.ddogleg.struct.VerbosePrint)10 SceneStructureProjective (boofcv.abst.geo.bundle.SceneStructureProjective)7 Se3_F64 (georegression.struct.se.Se3_F64)6 Test (org.junit.jupiter.api.Test)6 SceneStructureCommon (boofcv.abst.geo.bundle.SceneStructureCommon)5 Point2D_F64 (georegression.struct.point.Point2D_F64)4 Point3D_F64 (georegression.struct.point.Point3D_F64)4 Point4D_F64 (georegression.struct.point.Point4D_F64)4 DMatrixRMaj (org.ejml.data.DMatrixRMaj)4 CodecSceneStructureMetric (boofcv.alg.geo.bundle.CodecSceneStructureMetric)3 BundlePinholeSimplified (boofcv.alg.geo.bundle.cameras.BundlePinholeSimplified)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)2 TriangulateNViewsMetricH (boofcv.abst.geo.TriangulateNViewsMetricH)2 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)2 AssociatedTriple (boofcv.struct.geo.AssociatedTriple)2 PointIndex2D_F64 (boofcv.struct.geo.PointIndex2D_F64)2 ArrayList (java.util.ArrayList)2