Search in sources :

Example 86 with DMatrixRMaj

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

the class TestTrifocalLinearPoint7 method createSystem.

DMatrixRMaj createSystem(List<AssociatedTriple> observations) {
    int N = observations.size();
    DMatrixRMaj A = new DMatrixRMaj(4 * N, 27);
    for (int i = 0; i < N; i++) {
        AssociatedTriple T = observations.get(i);
        Point2D_F64 p1 = T.p1;
        Point2D_F64 p2 = T.p2;
        Point2D_F64 p3 = T.p3;
        for (int k = 0; k < 3; k++) {
            fillLine(A, i * 4, 0, 2, 0, 2, k, p1, p2, p3);
            fillLine(A, i * 4 + 1, 0, 2, 1, 2, k, p1, p2, p3);
            fillLine(A, i * 4 + 2, 1, 2, 0, 2, k, p1, p2, p3);
            fillLine(A, i * 4 + 3, 1, 2, 1, 2, k, p1, p2, p3);
        // not sure if this is the correct 9. need to think more
        // fillLine(A,i*4  ,0,1,0,1,k,p1,p2,p3);
        // fillLine(A,i*4+1,0,2,0,1,k,p1,p2,p3);
        // fillLine(A,i*4+2,0,2,0,2,k,p1,p2,p3);
        // fillLine(A,i*4+3,1,0,1,0,k,p1,p2,p3);
        // fillLine(A,i*4+4,1,2,1,0,k,p1,p2,p3);
        // fillLine(A,i*4+5,1,0,1,2,k,p1,p2,p3);
        // fillLine(A,i*4+6,2,0,2,0,k,p1,p2,p3);
        // fillLine(A,i*4+7,2,1,2,0,k,p1,p2,p3);
        // fillLine(A,i*4+8,2,1,2,1,k,p1,p2,p3);
        }
    }
    return A;
}
Also used : AssociatedTriple(boofcv.struct.geo.AssociatedTriple) Point2D_F64(georegression.struct.point.Point2D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Example 87 with DMatrixRMaj

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

the class CalibrationIO method loadOpenCV.

/**
 * Loads intrinsic parameters in OpenCV format.
 */
public static CameraPinholeBrown loadOpenCV(Reader reader) {
    CameraPinholeBrown out = new CameraPinholeBrown();
    try {
        String filtered = IOUtils.toString(reader);
        // It doesn't like the header or that class def
        filtered = filtered.replace("%YAML:1.0", "");
        filtered = filtered.replace("!!opencv-matrix", "");
        Representer representer = new Representer();
        representer.getPropertyUtils().setSkipMissingProperties(true);
        Yaml yaml = new Yaml(new Constructor(), representer);
        Map<String, Object> map = yaml.load(filtered);
        int width = getOrThrow(map, "image_width");
        int height = getOrThrow(map, "image_height");
        DMatrixRMaj K = loadOpenCVMatrix(getOrThrow(map, "camera_matrix"));
        DMatrixRMaj distortion = loadOpenCVMatrix(getOrThrow(map, "distortion_coefficients"));
        PerspectiveOps.matrixToPinhole(K, width, height, out);
        if (distortion.getNumElements() >= 5)
            out.setRadial(distortion.get(0), distortion.get(1), distortion.get(4));
        else if (distortion.getNumElements() >= 2)
            out.setRadial(distortion.get(0), distortion.get(1));
        if (distortion.getNumElements() >= 5)
            out.fsetTangental(distortion.get(2), distortion.get(3));
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return out;
}
Also used : Representer(org.yaml.snakeyaml.representer.Representer) Constructor(org.yaml.snakeyaml.constructor.Constructor) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Yaml(org.yaml.snakeyaml.Yaml)

Example 88 with DMatrixRMaj

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

the class TestTrifocalTensor method convertTo.

@Test
void convertTo() {
    TrifocalTensor t = new TrifocalTensor();
    for (int i = 0; i < 27; i++) t.getT(i / 9).set(i % 9, i);
    DMatrixRMaj A = new DMatrixRMaj(27, 1);
    t.convertTo(A);
    for (int i = 0; i < 27; i++) assertEquals(A.get(i), i);
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.jupiter.api.Test)

Example 89 with DMatrixRMaj

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

the class TestTrifocalTensor method convertFrom.

@Test
void convertFrom() {
    DMatrixRMaj A = new DMatrixRMaj(27, 1);
    for (int i = 0; i < 27; i++) A.set(i, i);
    TrifocalTensor t = new TrifocalTensor();
    t.convertFrom(A);
    for (int i = 0; i < 27; i++) assertEquals(t.getT(i / 9).get(i % 9), i);
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.jupiter.api.Test)

Example 90 with DMatrixRMaj

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

the class TestQueueMatrix method constructor_regular.

@Test
void constructor_regular() {
    QueueMatrix alg = new QueueMatrix(3, 4);
    assertEquals(0, alg.size);
    DMatrixRMaj M = alg.grow();
    assertEquals(3, M.numRows);
    assertEquals(4, M.numCols);
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.jupiter.api.Test)

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