Search in sources :

Example 81 with CameraPinholeBrown

use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.

the class TestVisOdomBundleAdjustment method createAlgSingleCamera.

private VisOdomBundleAdjustment<BTrack> createAlgSingleCamera() {
    var alg = new VisOdomBundleAdjustment<>(BTrack::new);
    alg.addCamera(new CameraPinholeBrown(0, 0, 0, 0, 0, 100, 200));
    return alg;
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) BTrack(boofcv.alg.sfm.d3.structure.VisOdomBundleAdjustment.BTrack)

Example 82 with CameraPinholeBrown

use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.

the class TestMonocularPlaneVisualOdometryScaleInput method process.

@Test
void process() {
    image = null;
    CameraPinholeBrown intrinsic = createIntrinsic();
    Dummy dummy = new Dummy();
    MonocularPlaneVisualOdometry<GrayF32> alg = new MonocularPlaneVisualOdometryScaleInput<>(dummy, 0.5);
    alg.setCalibration(new MonoPlaneParameters(intrinsic, new Se3_F64()));
    GrayF32 inputImage = new GrayF32(width, height);
    alg.process(inputImage);
    assertTrue(inputImage != image);
    assertEquals(320, image.width);
    assertEquals(160, image.height);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) MonoPlaneParameters(boofcv.struct.calib.MonoPlaneParameters) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Example 83 with CameraPinholeBrown

use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.

the class SceneMergingOperations method getCommonFeaturePixelsViews.

/**
 * Retrieves the pixel coordinates for all the other views in InlierInfo, excludes the first/target.
 *
 * @param db Used to look up image feature pixel coordinates
 * @param inliers List of image features that were part of the inlier set in all the views
 * @return List of observations in each view (expet the target) that are part of the inler and common set
 */
@SuppressWarnings("IntegerDivisionInFloatingPointContext")
List<DogArray<Point2D_F64>> getCommonFeaturePixelsViews(LookUpSimilarImages db, SceneWorkingGraph workingGraph, SceneWorkingGraph.InlierInfo inliers) {
    List<DogArray<Point2D_F64>> listViewPixels = new ArrayList<>();
    // Which features are inliers in view[0] / common view
    DogArray_I32 viewZeroInlierIdx = inliers.observations.get(0);
    // View 0 = common view and is skipped here
    int numViews = inliers.observations.size;
    for (int viewIdx = 1; viewIdx < numViews; viewIdx++) {
        // Retrieve the feature pixel coordinates for this view
        db.lookupPixelFeats(inliers.views.get(viewIdx).id, dbPixels);
        // Which features are part of the inlier set
        DogArray_I32 inlierIdx = inliers.observations.get(viewIdx);
        BoofMiscOps.checkEq(viewZeroInlierIdx.size, inlierIdx.size, "Inliers count should be the same");
        // Create storage for all the pixels in each view
        DogArray<Point2D_F64> viewPixels = new DogArray<>(Point2D_F64::new);
        listViewPixels.add(viewPixels);
        viewPixels.resize(zeroViewPixels.size);
        // camera model assumes pixels have been recentered
        SceneWorkingGraph.View wview = Objects.requireNonNull(workingGraph.views.get(inliers.views.get(viewIdx).id));
        SceneWorkingGraph.Camera camera = workingGraph.getViewCamera(wview);
        CameraPinholeBrown cameraPrior = camera.prior;
        // Add the inlier pixels from this view to the array in the correct order
        for (int idx = 0; idx < inlierIdx.size; idx++) {
            // feature ID in view[0]
            int viewZeroIdx = viewZeroInlierIdx.get(idx);
            // feature ID in the common list
            int commonFeatureIdx = zeroFeatureToCommonIndex.get(viewZeroIdx);
            if (commonFeatureIdx < 0)
                continue;
            // Copy the pixel from this view into the appropriate location
            Point2D_F64 p = viewPixels.get(commonFeatureIdx);
            p.setTo(dbPixels.get(inlierIdx.get(idx)));
            p.x -= cameraPrior.cx;
            p.y -= cameraPrior.cy;
        }
    }
    return listViewPixels;
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) DogArray_I32(org.ddogleg.struct.DogArray_I32) DogArray(org.ddogleg.struct.DogArray) VerbosePrint(org.ddogleg.struct.VerbosePrint)

Example 84 with CameraPinholeBrown

use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.

the class TestLookUpCameraInfo method addCameraCanonical.

@Test
void addCameraCanonical() {
    var alg = new LookUpCameraInfo();
    alg.addCameraCanonical(1000, 200, 45);
    CameraPinholeBrown found = alg.listCalibration.get(0);
    assertEquals(1000, found.width);
    assertEquals(200, found.height);
    assertEquals(500, found.cx);
    assertEquals(100, found.cy);
    double f = 500 / Math.tan(UtilAngle.degreeToRadian(45) / 2.0);
    assertEquals(1.0, f / found.fx, 1e-7);
    assertEquals(1.0, f / found.fy, 1e-7);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Test(org.junit.jupiter.api.Test)

Example 85 with CameraPinholeBrown

use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.

the class GenericDetectSingleFiducialCalibrationChecks method renderEasy.

protected GrayF32 renderEasy(ConfigGridDimen layout, List<Point2D_F64> locations2D) {
    CameraPinholeBrown model = CalibrationIO.load(getClass().getResource("pinhole_radial.yaml"));
    if (locations2D == null)
        locations2D = new ArrayList<>();
    GrayF32 pattern = new GrayF32(1, 1);
    renderTarget(layout, simulatedTargetWidth, pattern, locations2D);
    SimulatePlanarWorld simulator = new SimulatePlanarWorld();
    simulator.setCamera(model);
    Se3_F64 markerToWorld = SpecialEuclideanOps_F64.eulerXyz(0, 0, 0.5, 0, Math.PI, 0, null);
    simulator.addSurface(markerToWorld, simulatedTargetWidth, pattern);
    simulator.render();
    return simulator.getOutput();
}
Also used : SimulatePlanarWorld(boofcv.simulation.SimulatePlanarWorld) GrayF32(boofcv.struct.image.GrayF32) CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) ArrayList(java.util.ArrayList) Se3_F64(georegression.struct.se.Se3_F64)

Aggregations

CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)99 Test (org.junit.jupiter.api.Test)62 Se3_F64 (georegression.struct.se.Se3_F64)39 GrayF32 (boofcv.struct.image.GrayF32)29 Point2D_F64 (georegression.struct.point.Point2D_F64)19 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)16 LensDistortionBrown (boofcv.alg.distort.brown.LensDistortionBrown)14 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)14 BufferedImage (java.awt.image.BufferedImage)14 ArrayList (java.util.ArrayList)12 CameraPinhole (boofcv.struct.calib.CameraPinhole)11 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)10 DMatrixRMaj (org.ejml.data.DMatrixRMaj)10 File (java.io.File)9 StereoParameters (boofcv.struct.calib.StereoParameters)6 GrayU8 (boofcv.struct.image.GrayU8)6 Point3D_F64 (georegression.struct.point.Point3D_F64)6 ImageBase (boofcv.struct.image.ImageBase)5 ImageType (boofcv.struct.image.ImageType)5 DogArray (org.ddogleg.struct.DogArray)5