Search in sources :

Example 1 with HomographyDirectLinearTransform

use of boofcv.alg.geo.h.HomographyDirectLinearTransform in project BoofCV by lessthanoptimal.

the class CheckRefineHomography method perfectInput.

@Test
public void perfectInput() {
    createScene(30, false);
    // use the linear algorithm to compute the homography
    HomographyDirectLinearTransform estimator = new HomographyDirectLinearTransform(true);
    estimator.process(pairs, H);
    ModelFitter<DMatrixRMaj, AssociatedPair> alg = createAlgorithm();
    // give it the perfect matrix and see if it screwed it up
    assertTrue(alg.fitModel(pairs, H, found));
    // normalize so that they are the same
    CommonOps_DDRM.divide(H, H.get(2, 2));
    CommonOps_DDRM.divide(found, found.get(2, 2));
    assertTrue(MatrixFeatures_DDRM.isEquals(H, found, 1e-8));
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) HomographyDirectLinearTransform(boofcv.alg.geo.h.HomographyDirectLinearTransform) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 2 with HomographyDirectLinearTransform

use of boofcv.alg.geo.h.HomographyDirectLinearTransform in project BoofCV by lessthanoptimal.

the class CheckRefineHomography method incorrectInput.

@Test
public void incorrectInput() {
    createScene(30, false);
    // use the linear algorithm to compute the homography
    HomographyDirectLinearTransform estimator = new HomographyDirectLinearTransform(true);
    estimator.process(pairs, H);
    ModelFitter<DMatrixRMaj, AssociatedPair> alg = createAlgorithm();
    // give it the perfect matrix and see if it screwed it up
    DMatrixRMaj Hmod = H.copy();
    Hmod.data[0] += 0.1;
    Hmod.data[5] += 0.1;
    assertTrue(alg.fitModel(pairs, Hmod, found));
    // normalize to allow comparison
    CommonOps_DDRM.divide(H, H.get(2, 2));
    CommonOps_DDRM.divide(Hmod, Hmod.get(2, 2));
    CommonOps_DDRM.divide(found, found.get(2, 2));
    double error0 = 0;
    double error1 = 0;
    // very crude error metric
    for (int i = 0; i < 9; i++) {
        error0 += Math.abs(Hmod.data[i] - H.data[i]);
        error1 += Math.abs(found.data[i] - H.data[i]);
    }
    // System.out.println("error "+error1);
    assertTrue(error1 < error0);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) HomographyDirectLinearTransform(boofcv.alg.geo.h.HomographyDirectLinearTransform) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Aggregations

HomographyDirectLinearTransform (boofcv.alg.geo.h.HomographyDirectLinearTransform)2 AssociatedPair (boofcv.struct.geo.AssociatedPair)2 DMatrixRMaj (org.ejml.data.DMatrixRMaj)2 Test (org.junit.Test)2