Search in sources :

Example 56 with AssociatedPair

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

the class BenchmarkStabilityFundamental method createObservations.

public void createObservations() {
    observations = new ArrayList<>();
    for (Point3D_F64 p1 : scene) {
        Point3D_F64 p2 = SePointOps_F64.transform(motion, p1, null);
        if (p1.z < 0 || p2.z < 0)
            continue;
        AssociatedPair pair = new AssociatedPair();
        pair.p1.set(p1.x / p1.z, p1.y / p1.z);
        pair.p2.set(p2.x / p2.z, p2.y / p2.z);
        observations.add(pair);
        // convert to pixels
        GeometryMath_F64.mult(K, pair.p1, pair.p1);
        GeometryMath_F64.mult(K, pair.p2, pair.p2);
        // add noise
        pair.p1.x += rand.nextGaussian() * sigmaPixels;
        pair.p1.y += rand.nextGaussian() * sigmaPixels;
        pair.p2.x += rand.nextGaussian() * sigmaPixels;
        pair.p2.y += rand.nextGaussian() * sigmaPixels;
        // if needed, convert back into normalized image coordinates
        if (!isPixels) {
            GeometryMath_F64.mult(K_inv, pair.p1, pair.p1);
            GeometryMath_F64.mult(K_inv, pair.p2, pair.p2);
        }
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point3D_F64(georegression.struct.point.Point3D_F64)

Example 57 with AssociatedPair

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

the class FunctionSampsonFundamental method process.

@Override
public double process(double[] input) {
    param.decode(input, F);
    double sum = 0;
    for (int i = 0; i < obs.size(); i++) {
        AssociatedPair p = obs.get(i);
        double top = GeometryMath_F64.innerProd(p.p2, F, p.p1);
        top *= top;
        double bottom = 0;
        GeometryMath_F64.mult(F, p.p1, temp);
        bottom += temp.x * temp.x + temp.y * temp.y;
        GeometryMath_F64.multTran(F, p.p2, temp);
        bottom += temp.x * temp.x + temp.y * temp.y;
        if (bottom <= 1e-12)
            continue;
        sum += top / bottom;
    }
    return sum;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair)

Example 58 with AssociatedPair

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

the class ResidualsEpipolarMatrix method process.

@Override
public void process(double[] input, double[] output) {
    param.decode(input, F);
    residual.setModel(F);
    for (int i = 0; i < obs.size(); i++) {
        AssociatedPair p = obs.get(i);
        output[i] = residual.computeResidual(p);
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair)

Example 59 with AssociatedPair

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

the class ResidualsEpipolarMatrixN method process.

@Override
public void process(double[] input, double[] output) {
    param.decode(input, F);
    residual.setModel(F);
    int index = 0;
    for (int i = 0; i < obs.size(); i++) {
        AssociatedPair p = obs.get(i);
        index = residual.computeResiduals(p, output, index);
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair)

Example 60 with AssociatedPair

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

the class ArtificialStereoScene method addPixelNoise.

public void addPixelNoise(double noiseSigma) {
    for (AssociatedPair p : pairs) {
        if (!isPixels) {
            PerspectiveOps.convertNormToPixel(K, p.p1, p.p1);
            PerspectiveOps.convertNormToPixel(K, p.p2, p.p2);
        }
        p.p2.x += rand.nextGaussian() * noiseSigma;
        p.p2.y += rand.nextGaussian() * noiseSigma;
        p.p1.x += rand.nextGaussian() * noiseSigma;
        p.p1.y += rand.nextGaussian() * noiseSigma;
        if (!isPixels) {
            PerspectiveOps.convertPixelToNorm(K, p.p1, p.p1);
            PerspectiveOps.convertPixelToNorm(K, p.p2, p.p2);
        }
    }
// observationCurrent simply references the data in pairs
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair)

Aggregations

AssociatedPair (boofcv.struct.geo.AssociatedPair)110 Test (org.junit.Test)32 Point2D_F64 (georegression.struct.point.Point2D_F64)28 ArrayList (java.util.ArrayList)27 DMatrixRMaj (org.ejml.data.DMatrixRMaj)22 Se3_F64 (georegression.struct.se.Se3_F64)17 Point3D_F64 (georegression.struct.point.Point3D_F64)12 ScaleTranslate2D (boofcv.struct.sfm.ScaleTranslate2D)7 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)6 Estimate1ofEpipolar (boofcv.abst.geo.Estimate1ofEpipolar)5 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)4 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)4 ScaleTranslateRotate2D (boofcv.struct.sfm.ScaleTranslateRotate2D)4 ClosestPoint3D_F64 (georegression.metric.ClosestPoint3D_F64)4 ConfigFastHessian (boofcv.abst.feature.detect.interest.ConfigFastHessian)3 TriangulateTwoViewsCalibrated (boofcv.abst.geo.TriangulateTwoViewsCalibrated)3 AssociationPanel (boofcv.gui.feature.AssociationPanel)3 BrightFeature (boofcv.struct.feature.BrightFeature)3 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)3 Ransac (org.ddogleg.fitting.modelset.ransac.Ransac)3