Search in sources :

Example 41 with AssociatedTriple

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

the class TestDistanceTrifocalTransferSq method noise.

@Test
void noise() {
    // estimate the tensors to ensure it's in pixels
    ConfigTrifocal config = new ConfigTrifocal();
    config.which = EnumTrifocal.LINEAR_7;
    FactoryMultiView.trifocal_1(config).process(observationsPixels, found);
    DistanceTrifocalTransferSq alg = new DistanceTrifocalTransferSq();
    alg.setModel(found);
    double error = 0.5;
    AssociatedTriple tmp = new AssociatedTriple();
    for (AssociatedTriple a : observationsPixels) {
        tmp.setTo(a);
        tmp.p3.x += error;
        // the error will be larger than this value but not too much larger
        double min = error * error;
        double max = 1.5 * min;
        double found = alg.distance(tmp);
        assertTrue(found >= min && found <= max);
    }
}
Also used : AssociatedTriple(boofcv.struct.geo.AssociatedTriple) ConfigTrifocal(boofcv.factory.geo.ConfigTrifocal) Test(org.junit.jupiter.api.Test)

Example 42 with AssociatedTriple

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

the class CommonTrifocalChecks method createSceneObservations.

void createSceneObservations(boolean planar) {
    P1_k = PerspectiveOps.createCameraMatrix(worldToCam1.R, worldToCam1.T, K, null);
    // P1 = [I|0]
    P2 = PerspectiveOps.createCameraMatrix(worldToCam2.R, worldToCam2.T, K, null);
    P3 = PerspectiveOps.createCameraMatrix(worldToCam3.R, worldToCam3.T, K, null);
    tensor = MultiViewOps.createTrifocal(P2, P3, null);
    tensorPixels = MultiViewOps.createTrifocal(P1_k, P2, P3, null);
    F2 = MultiViewOps.createEssential(worldToCam2.getR(), worldToCam2.getT(), null);
    F2 = MultiViewOps.createFundamental(F2, K);
    F3 = MultiViewOps.createEssential(worldToCam3.getR(), worldToCam3.getT(), null);
    F3 = MultiViewOps.createFundamental(F3, K);
    observations = new ArrayList<>();
    observationsPixels = new ArrayList<>();
    observationsNorm = new ArrayList<>();
    for (int i = 0; i < numFeatures; i++) {
        Point3D_F64 p = new Point3D_F64();
        p.x = rand.nextGaussian() * 0.5;
        p.y = rand.nextGaussian() * 0.5;
        if (planar) {
            p.z = 2;
        } else {
            p.z = rand.nextGaussian() * 0.5 + 2;
        }
        worldPts.add(p);
        AssociatedTriple o = new AssociatedTriple();
        o.p1 = PerspectiveOps.renderPixel(new Se3_F64(), p, null);
        o.p2 = PerspectiveOps.renderPixel(P2, p);
        o.p3 = PerspectiveOps.renderPixel(P3, p);
        AssociatedTriple oP = new AssociatedTriple();
        oP.p1 = PerspectiveOps.renderPixel(new Se3_F64(), K, p, null);
        oP.p2 = PerspectiveOps.renderPixel(P2, p);
        oP.p3 = PerspectiveOps.renderPixel(P3, p);
        AssociatedTriple oN = new AssociatedTriple();
        oN.p1 = PerspectiveOps.renderPixel(new Se3_F64(), p, null);
        oN.p2 = PerspectiveOps.renderPixel(worldToCam2, p, null);
        oN.p3 = PerspectiveOps.renderPixel(worldToCam3, p, null);
        observations.add(o);
        observationsPixels.add(oP);
        observationsNorm.add(oN);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) AssociatedTriple(boofcv.struct.geo.AssociatedTriple) Se3_F64(georegression.struct.se.Se3_F64)

Example 43 with AssociatedTriple

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

the class TestTrifocalAlgebraicPoint7 method computeTransferError.

/**
 * Computes the error using induced homographies.
 */
double computeTransferError(TrifocalTensor tensor, List<AssociatedTriple> observations) {
    TrifocalTransfer transfer = new TrifocalTransfer();
    transfer.setTrifocal(tensor);
    double errors = 0;
    for (AssociatedTriple o : observations) {
        Point3D_F64 p = new Point3D_F64();
        transfer.transfer_1_to_3(o.p1.x, o.p1.y, o.p2.x, o.p2.y, p);
        errors += o.p3.distance(p.x / p.z, p.y / p.z);
        transfer.transfer_1_to_2(o.p1.x, o.p1.y, o.p3.x, o.p3.y, p);
        errors += o.p2.distance(p.x / p.z, p.y / p.z);
    }
    return errors / (2 * observations.size());
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) AssociatedTriple(boofcv.struct.geo.AssociatedTriple)

Aggregations

AssociatedTriple (boofcv.struct.geo.AssociatedTriple)43 DMatrixRMaj (org.ejml.data.DMatrixRMaj)12 Test (org.junit.jupiter.api.Test)12 ArrayList (java.util.ArrayList)11 Point2D_F64 (georegression.struct.point.Point2D_F64)9 TrifocalTensor (boofcv.struct.geo.TrifocalTensor)6 Point3D_F64 (georegression.struct.point.Point3D_F64)6 ConfigTrifocal (boofcv.factory.geo.ConfigTrifocal)5 Se3_F64 (georegression.struct.se.Se3_F64)5 VerbosePrint (org.ddogleg.struct.VerbosePrint)5 SceneObservations (boofcv.abst.geo.bundle.SceneObservations)4 BundlePinholeSimplified (boofcv.alg.geo.bundle.cameras.BundlePinholeSimplified)4 SceneStructureMetric (boofcv.abst.geo.bundle.SceneStructureMetric)3 AssociatedTriplePanel (boofcv.gui.feature.AssociatedTriplePanel)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 GrayU8 (boofcv.struct.image.GrayU8)3 Point4D_F64 (georegression.struct.point.Point4D_F64)3 DogArray (org.ddogleg.struct.DogArray)3 ConfigFastHessian (boofcv.abst.feature.detect.interest.ConfigFastHessian)2 Estimate1ofTrifocalTensor (boofcv.abst.geo.Estimate1ofTrifocalTensor)2