Search in sources :

Example 21 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class TestZhang99ComputeTargetHomography method basicTest.

public void basicTest(boolean removeAFew) {
    // create a grid an apply an arbitrary transform to it
    List<Point2D_F64> layout = GenericCalibrationGrid.standardLayout();
    DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.02, -0.05, 0.01, null);
    Vector3D_F64 T = new Vector3D_F64(0, 0, -1000);
    Se3_F64 motion = new Se3_F64(R, T);
    CalibrationObservation observations = GenericCalibrationGrid.observations(motion, layout);
    if (removeAFew) {
        for (int i = 0; i < 6; i++) {
            observations.points.remove(5);
        }
    }
    // compute the homography
    Zhang99ComputeTargetHomography alg = new Zhang99ComputeTargetHomography(layout);
    assertTrue(alg.computeHomography(observations));
    DMatrixRMaj H = alg.getHomography();
    // test this homography property: x2 = H*x1
    for (int i = 0; i < observations.size(); i++) {
        int gridIndex = observations.get(i).index;
        Point2D_F64 p = observations.get(i);
        Point2D_F64 a = GeometryMath_F64.mult(H, layout.get(gridIndex), new Point2D_F64());
        double diff = a.distance(p);
        assertEquals(0, diff, 1e-8);
    }
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64)

Example 22 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class TestTrifocalAlgebraicPoint7 method checkInducedErrors.

/**
 * Computes the error using induced homographies.
 */
public void checkInducedErrors(TrifocalTensor tensor, List<AssociatedTriple> observations, double tol) {
    for (AssociatedTriple o : observations) {
        // homogeneous vector for observations in views 2 and 3
        Vector3D_F64 obs2 = new Vector3D_F64(o.p2.x, o.p2.y, 1);
        Vector3D_F64 obs3 = new Vector3D_F64(o.p3.x, o.p3.y, 1);
        // compute lines which pass through the observations
        Vector3D_F64 axisY = new Vector3D_F64(0, 1, 0);
        Vector3D_F64 line2 = new Vector3D_F64();
        Vector3D_F64 line3 = new Vector3D_F64();
        GeometryMath_F64.cross(obs2, axisY, line2);
        GeometryMath_F64.cross(obs3, axisY, line3);
        // compute induced homographies
        DMatrixRMaj H12 = MultiViewOps.inducedHomography12(tensor, line3, null);
        DMatrixRMaj H13 = MultiViewOps.inducedHomography13(tensor, line2, null);
        Point2D_F64 induced2 = new Point2D_F64();
        Point2D_F64 induced3 = new Point2D_F64();
        GeometryMath_F64.mult(H12, o.p1, induced2);
        GeometryMath_F64.mult(H13, o.p1, induced3);
        assertEquals(0, induced2.distance(o.p2), tol);
        assertEquals(0, induced3.distance(o.p3), tol);
    }
}
Also used : AssociatedTriple(boofcv.struct.geo.AssociatedTriple) Vector3D_F64(georegression.struct.point.Vector3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Example 23 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class TestDetectCircleRegularGrid method checkCounterClockWise.

static void checkCounterClockWise(Grid g) {
    EllipseRotated_F64 a = g.get(0, 0);
    EllipseRotated_F64 b = g.get(0, 1);
    EllipseRotated_F64 c = g.get(1, 0);
    double dx0 = b.center.x - a.center.x;
    double dy0 = b.center.y - a.center.y;
    double dx1 = c.center.x - a.center.x;
    double dy1 = c.center.y - a.center.y;
    Vector3D_F64 v = new Vector3D_F64();
    GeometryMath_F64.cross(dx0, dy0, 0, dx1, dy1, 0, v);
    assertTrue(v.z > 0);
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64)

Example 24 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class VisualOdometryPanel method setCameraToWorld.

public void setCameraToWorld(Se3_F64 cameraToWorld) {
    displayX.setText(String.format("%6.1f", cameraToWorld.getT().x));
    displayY.setText(String.format("%6.1f", cameraToWorld.getT().y));
    displayZ.setText(String.format("%6.1f", cameraToWorld.getT().z));
    Vector3D_F64 v = new Vector3D_F64(0, 0, 1);
    GeometryMath_F64.mult(cameraToWorld.getR(), v, v);
    orientation.setVector(v);
    orientation.repaint();
    displayOrigin.setText(String.format("%6.1f", cameraToWorld.getT().norm()));
    if (prevToWorld == null) {
        prevToWorld = cameraToWorld.copy();
    } else {
        Se3_F64 worldToPrev = prevToWorld.invert(null);
        cameraToWorld.concat(worldToPrev, prevToWorld);
        integral += prevToWorld.getT().norm();
        prevToWorld.set(cameraToWorld);
    }
    displayIntegral.setText(String.format("%6.1f", integral));
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) Se3_F64(georegression.struct.se.Se3_F64)

Example 25 with Vector3D_F64

use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.

the class VisualOdometryPanel2 method setCameraToWorld.

public void setCameraToWorld(Se3_F64 cameraToWorld) {
    Vector3D_F64 v = new Vector3D_F64(0, 0, 1);
    GeometryMath_F64.mult(cameraToWorld.getR(), v, v);
    orientation.setVector(v);
    orientation.repaint();
    displayOrigin.setText(String.format("%6.1f", cameraToWorld.getT().norm()));
    if (prevToWorld == null) {
        prevToWorld = cameraToWorld.copy();
    } else {
        Se3_F64 worldToPrev = prevToWorld.invert(null);
        cameraToWorld.concat(worldToPrev, prevToWorld);
        integral += prevToWorld.getT().norm();
        prevToWorld.set(cameraToWorld);
    }
    displayIntegral.setText(String.format("%6.1f", integral));
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) Se3_F64(georegression.struct.se.Se3_F64)

Aggregations

Vector3D_F64 (georegression.struct.point.Vector3D_F64)60 DMatrixRMaj (org.ejml.data.DMatrixRMaj)34 Se3_F64 (georegression.struct.se.Se3_F64)30 Test (org.junit.Test)23 Point3D_F64 (georegression.struct.point.Point3D_F64)15 Point2D_F64 (georegression.struct.point.Point2D_F64)13 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)4 PkltConfig (boofcv.alg.tracker.klt.PkltConfig)4 GrayU8 (boofcv.struct.image.GrayU8)4 MediaManager (boofcv.io.MediaManager)3 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)3 ArrayList (java.util.ArrayList)3 GrayU16 (boofcv.struct.image.GrayU16)2 UtilVector3D_F64 (georegression.geometry.UtilVector3D_F64)2 GeometryUnitTest (georegression.misc.test.GeometryUnitTest)2 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)2 Random (java.util.Random)2 SimpleMatrix (org.ejml.simple.SimpleMatrix)2 ConfigChessboard (boofcv.abst.fiducial.calib.ConfigChessboard)1 AccessPointTracks3D (boofcv.abst.sfm.AccessPointTracks3D)1