Search in sources :

Example 16 with AssociatedPair

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

the class CommonHomographyChecks method createScene.

public void createScene(int numPoints, boolean isPixels) {
    // define the camera's motion
    motion = new Se3_F64();
    motion.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.05, -0.03, 0.02, null));
    motion.getT().set(0.1, -0.1, 0.01);
    // randomly generate points in space
    pts = createRandomPlane(rand, d, numPoints);
    // transform points into second camera's reference frame
    pairs = new ArrayList<>();
    for (Point3D_F64 p1 : pts) {
        Point3D_F64 p2 = SePointOps_F64.transform(motion, p1, null);
        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);
        pairs.add(pair);
        if (isPixels) {
            GeometryMath_F64.mult(K, pair.p1, pair.p1);
            GeometryMath_F64.mult(K, pair.p2, pair.p2);
        }
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point3D_F64(georegression.struct.point.Point3D_F64) Se3_F64(georegression.struct.se.Se3_F64)

Example 17 with AssociatedPair

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

the class TestHomographyDirectLinearTransform method checkHomography.

/**
 * Create a set of points perfectly on a plane and provide perfect observations of them
 *
 * @param N Number of observed points.
 * @param isPixels Pixel or calibrated coordinates
 * @param alg Algorithm being evaluated
 */
private void checkHomography(int N, boolean isPixels, HomographyDirectLinearTransform alg) {
    createScene(N, isPixels);
    // compute essential
    assertTrue(alg.process(pairs, solution));
    // validate by testing essential properties
    // sanity check, F is not zero
    assertTrue(NormOps_DDRM.normF(solution) > 0.001);
    // see if it follows the epipolar constraint
    for (AssociatedPair p : pairs) {
        Point2D_F64 a = GeometryMath_F64.mult(solution, p.p1, new Point2D_F64());
        double diff = a.distance(p.p2);
        assertEquals(0, diff, 1e-8);
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64)

Example 18 with AssociatedPair

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

the class TestHomographyTotalLeastSquares method checkAgainstKnownH.

@Test
public void checkAgainstKnownH() {
    DMatrixRMaj H = new DMatrixRMaj(new double[][] { { 1.5, 0, 0.5 }, { 0.2, 2, 0.2 }, { 0.05, 0, 1.5 } });
    // DMatrixRMaj H = new DMatrixRMaj(new double[][]{{1,0,0},{0,1,0},{0,0,1}});
    // DMatrixRMaj H = new DMatrixRMaj(new double[][]{{1,0,0},{0,1,0},{0,0,2.0}});
    int N = 10000;
    List<AssociatedPair> list = new ArrayList<>();
    for (int i = 0; i < N; i++) {
        AssociatedPair p = new AssociatedPair();
        p.p1.x = rand.nextGaussian();
        p.p1.y = rand.nextGaussian();
        GeometryMath_F64.mult(H, p.p1, p.p2);
        list.add(p);
    }
    CommonOps_DDRM.scale(1.0 / H.get(2, 2), H);
    // H.print();
    DMatrixRMaj found = new DMatrixRMaj(3, 3);
    HomographyTotalLeastSquares alg = new HomographyTotalLeastSquares();
    alg.process(list, found);
    // System.out.println("\n\nFound");
    // found.print();
    assertTrue(MatrixFeatures_DDRM.isIdentical(found, H, UtilEjml.TEST_F64));
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) DMatrixRMaj(org.ejml.data.DMatrixRMaj) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 19 with AssociatedPair

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

the class TestDistanceAffine2D method createRandomData.

@Override
public AssociatedPair createRandomData() {
    Point2D_F64 p1 = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
    Point2D_F64 p2 = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
    return new AssociatedPair(p1, p2, false);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64)

Example 20 with AssociatedPair

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

the class TestDistanceHomographyPixelSq method createRandomData.

@Override
public AssociatedPair createRandomData() {
    Point2D_F64 p1 = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
    Point2D_F64 p2 = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
    return new AssociatedPair(p1, p2, false);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64)

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