Search in sources :

Example 6 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestPerspectiveOps method calibrationMatrix.

@Test
public void calibrationMatrix() {
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(1.0, 2, 3, 4, 5);
    assertEquals(1, K.get(0, 0), 1e-3);
    assertEquals(2, K.get(1, 1), 1e-3);
    assertEquals(3, K.get(0, 1), 1e-3);
    assertEquals(4, K.get(0, 2), 1e-3);
    assertEquals(5, K.get(1, 2), 1e-3);
    assertEquals(1, K.get(2, 2), 1e-3);
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 7 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestPerspectiveOps method matrixToParam.

@Test
public void matrixToParam() {
    double fx = 1;
    double fy = 2;
    double skew = 3;
    double cx = 4;
    double cy = 5;
    DMatrixRMaj K = new DMatrixRMaj(3, 3, true, fx, skew, cx, 0, fy, cy, 0, 0, 1);
    CameraPinhole ret = PerspectiveOps.matrixToParam(K, 100, 200, null);
    assertTrue(ret.fx == fx);
    assertTrue(ret.fy == fy);
    assertTrue(ret.skew == skew);
    assertTrue(ret.cx == cx);
    assertTrue(ret.cy == cy);
    assertTrue(ret.width == 100);
    assertTrue(ret.height == 200);
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.Test)

Example 8 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestPositiveDepthConstraintCheck method testPositive.

/**
 * Point a point in front of both cameras and see if it returns true
 */
@Test
public void testPositive() {
    // create transform from A to B
    DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -0.05, 0, null);
    Vector3D_F64 T = new Vector3D_F64(1, 0, 0);
    Se3_F64 fromAtoB = new Se3_F64(R, T);
    // point in front of both cameras
    Point3D_F64 pt = new Point3D_F64(0, 0, 2);
    // create observations of the point in calibrated coordinates
    Point2D_F64 obsA = new Point2D_F64(0, 0);
    Point3D_F64 pt_inB = SePointOps_F64.transform(fromAtoB, pt, null);
    Point2D_F64 obsB = new Point2D_F64(pt_inB.x / pt_inB.z, pt_inB.y / pt_inB.z);
    PositiveDepthConstraintCheck alg = new PositiveDepthConstraintCheck();
    assertTrue(alg.checkConstraint(obsA, obsB, fromAtoB));
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) 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) Test(org.junit.Test)

Example 9 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.

the class TestRemoveRadialPtoN_F64 method checkAgainstAdd.

public void checkAgainstAdd(double t1, double t2) {
    double fx = 600;
    double fy = 500;
    double skew = 2;
    double xc = 300;
    double yc = 350;
    /**/
    double[] radial = new /**/
    double[] { 0.12, -0.13 };
    Point2D_F64 point = new Point2D_F64();
    double undistX = 19.5;
    double undistY = 200.1;
    AddRadialPtoN_F64 p_to_n = new AddRadialPtoN_F64().setK(fx, fy, skew, xc, yc).setDistortion(radial, t1, t2);
    new Transform2ThenPixel_F64(p_to_n).set(fx, fy, skew, xc, yc).compute(undistX, undistY, point);
    double distX = point.x;
    double distY = point.y;
    RemoveRadialPtoN_F64 alg = new RemoveRadialPtoN_F64().setK(fx, fy, skew, xc, yc).setDistortion(radial, t1, t2);
    alg.compute(distX, distY, point);
    // / go from calibrated coordinates to pixel
    DMatrixRMaj K = PerspectiveOps.calibrationMatrix(fx, fy, skew, xc, yc);
    GeometryMath_F64.mult(K, point, point);
    assertEquals(undistX, point.x, GrlConstants.TEST_SQ_F64);
    assertEquals(undistY, point.y, GrlConstants.TEST_SQ_F64);
}
Also used : Transform2ThenPixel_F64(boofcv.alg.distort.Transform2ThenPixel_F64) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Example 10 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.

the class CalibrateStereoPlanarGuiApp method setRectification.

/**
 * Computes stereo rectification and then passes the distortion along to the gui.
 */
private void setRectification(final StereoParameters param) {
    // calibration matrix for left and right camera
    DMatrixRMaj K1 = PerspectiveOps.calibrationMatrix(param.getLeft(), (DMatrixRMaj) null);
    DMatrixRMaj K2 = PerspectiveOps.calibrationMatrix(param.getRight(), (DMatrixRMaj) null);
    RectifyCalibrated rectify = RectifyImageOps.createCalibrated();
    rectify.process(K1, new Se3_F64(), K2, param.getRightToLeft().invert(null));
    final DMatrixRMaj rect1 = rectify.getRect1();
    final DMatrixRMaj rect2 = rectify.getRect2();
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            gui.setRectification(param.getLeft(), rect1, param.getRight(), rect2);
        }
    });
    gui.repaint();
}
Also used : RectifyCalibrated(boofcv.alg.geo.rectify.RectifyCalibrated) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Se3_F64(georegression.struct.se.Se3_F64)

Aggregations

DMatrixRMaj (org.ejml.data.DMatrixRMaj)454 Test (org.junit.jupiter.api.Test)210 Se3_F64 (georegression.struct.se.Se3_F64)107 Point2D_F64 (georegression.struct.point.Point2D_F64)87 Point3D_F64 (georegression.struct.point.Point3D_F64)68 ArrayList (java.util.ArrayList)55 Vector3D_F64 (georegression.struct.point.Vector3D_F64)54 AssociatedPair (boofcv.struct.geo.AssociatedPair)38 CameraPinhole (boofcv.struct.calib.CameraPinhole)32 Equation (org.ejml.equation.Equation)29 UtilPoint3D_F64 (georegression.geometry.UtilPoint3D_F64)25 Point4D_F64 (georegression.struct.point.Point4D_F64)19 StringReader (java.io.StringReader)16 Test (org.junit.Test)15 AssociatedTriple (boofcv.struct.geo.AssociatedTriple)12 TrifocalTensor (boofcv.struct.geo.TrifocalTensor)11 RectifyCalibrated (boofcv.alg.geo.rectify.RectifyCalibrated)10 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)10 BufferedImage (java.awt.image.BufferedImage)10 SceneStructureProjective (boofcv.abst.geo.bundle.SceneStructureProjective)9