Search in sources :

Example 1 with UtilPoint4D_F64

use of georegression.geometry.UtilPoint4D_F64 in project BoofCV by lessthanoptimal.

the class TestPruneStructureFromSceneProjective method createPerfectScene.

private void createPerfectScene() {
    structure = new SceneStructureProjective(true);
    structure.initialize(10, 500);
    CameraPinhole intrinsic = new CameraPinhole(400, 410, 0.1, 500, 501, 1000, 1000);
    DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(intrinsic, (DMatrixRMaj) null);
    for (int viewIdx = 0; viewIdx < structure.views.size; viewIdx++) {
        Se3_F64 worldToView = new Se3_F64();
        if (viewIdx > 0) {
            worldToView.T.x = rand.nextGaussian() * 0.5;
            worldToView.T.y = rand.nextGaussian() * 0.5;
            worldToView.T.z = rand.nextGaussian() * 0.05;
            // increased rotation variance until a few of the points weren't always visible
            ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, rand.nextGaussian() * 0.5, rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.1, worldToView.R);
        }
        DMatrixRMaj cameraMatrix = PerspectiveOps.createCameraMatrix(worldToView.R, worldToView.T, K, null);
        structure.setView(viewIdx, viewIdx == 0, cameraMatrix, intrinsic.width, intrinsic.height);
    }
    List<Point4D_F64> points = UtilPoint4D_F64.randomN(center, 1.0, 0.5, structure.points.size, rand);
    for (int i = 0; i < points.size(); i++) {
        Point4D_F64 p = points.get(i);
        double s = rand.nextGaussian();
        if (// make sure it isn't scaled by zero
        Math.abs(s) < 1e-5)
            s = rand.nextDouble() + 0.01;
        p.scale(s);
        structure.points.data[i].set(p.x, p.y, p.z, p.w);
    }
    createRestOfScene();
}
Also used : SceneStructureProjective(boofcv.abst.geo.bundle.SceneStructureProjective) DMatrixRMaj(org.ejml.data.DMatrixRMaj) UtilPoint4D_F64(georegression.geometry.UtilPoint4D_F64) Point4D_F64(georegression.struct.point.Point4D_F64) CameraPinhole(boofcv.struct.calib.CameraPinhole) Se3_F64(georegression.struct.se.Se3_F64)

Aggregations

SceneStructureProjective (boofcv.abst.geo.bundle.SceneStructureProjective)1 CameraPinhole (boofcv.struct.calib.CameraPinhole)1 UtilPoint4D_F64 (georegression.geometry.UtilPoint4D_F64)1 Point4D_F64 (georegression.struct.point.Point4D_F64)1 Se3_F64 (georegression.struct.se.Se3_F64)1 DMatrixRMaj (org.ejml.data.DMatrixRMaj)1