Search in sources :

Example 26 with StereoParameters

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

the class TestPnPStereoResidualReprojection method compareToReprojection.

@Test
void compareToReprojection() {
    Se3_F64 worldToLeft = new Se3_F64();
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, 1, -0.2, worldToLeft.getR());
    worldToLeft.getT().setTo(-0.3, 0.4, 1);
    generateScene(10, worldToLeft, false);
    // make the input model incorrect
    worldToLeft.getR().set(2, 1, 2);
    // compute the error in normalized image coordinates per element
    PnPStereoResidualReprojection alg = new PnPStereoResidualReprojection();
    alg.setModel(new StereoPose(worldToLeft, leftToRight));
    // compute errors with perfect model
    double[] error = new double[alg.getN()];
    alg.computeResiduals(pointPose.get(0), error, 0);
    double found = 0;
    for (double e : error) {
        found += e * e;
    }
    PnPStereoDistanceReprojectionSq validation = new PnPStereoDistanceReprojectionSq();
    StereoParameters param = new StereoParameters();
    param.right_to_left = this.param.right_to_left;
    // intrinsic parameters are configured to be identical to normalized image coordinates
    param.left = new CameraPinholeBrown(1, 1, 0, 0, 0, 0, 0).fsetRadial(0, 0);
    param.right = new CameraPinholeBrown(1, 1, 0, 0, 0, 0, 0).fsetRadial(0, 0);
    validation.setStereoParameters(param);
    validation.setModel(worldToLeft);
    double expected = validation.distance(pointPose.get(0));
    assertEquals(expected, found, 1e-8);
}
Also used : StereoPose(boofcv.struct.sfm.StereoPose) CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) StereoParameters(boofcv.struct.calib.StereoParameters) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Example 27 with StereoParameters

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

the class CheckVisualOdometryStereoSim method changeInputSize.

@Test
void changeInputSize() {
    StereoVisualOdometry<I> algorithm = createAlgorithm();
    I leftSmall = GeneralizedImageOps.createSingleBand(inputType, width / 2, height / 2);
    I rightSmall = GeneralizedImageOps.createSingleBand(inputType, width / 2, height / 2);
    I leftLarge = GeneralizedImageOps.createSingleBand(inputType, width, height);
    I rightLarge = GeneralizedImageOps.createSingleBand(inputType, width, height);
    GImageMiscOps.fillUniform(leftSmall, rand, 0, 100);
    GImageMiscOps.fillUniform(leftSmall, rand, 0, 100);
    GImageMiscOps.fillUniform(leftLarge, rand, 0, 100);
    GImageMiscOps.fillUniform(rightLarge, rand, 0, 100);
    StereoParameters paramSmall = createStereoParam();
    paramSmall.left.width = paramSmall.right.width = leftSmall.width;
    paramSmall.left.height = paramSmall.right.height = leftSmall.height;
    algorithm.reset();
    algorithm.setCalibration(paramSmall);
    assertTrue(algorithm.process(leftSmall, rightSmall));
    StereoParameters paramLarge = createStereoParam();
    paramLarge.left.width = paramLarge.right.width = leftLarge.width;
    paramLarge.left.height = paramLarge.right.height = leftLarge.height;
    algorithm.reset();
    algorithm.setCalibration(paramLarge);
    assertTrue(algorithm.process(leftLarge, rightSmall));
}
Also used : StereoParameters(boofcv.struct.calib.StereoParameters) Test(org.junit.jupiter.api.Test)

Aggregations

StereoParameters (boofcv.struct.calib.StereoParameters)27 Se3_F64 (georegression.struct.se.Se3_F64)12 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)9 BufferedImage (java.awt.image.BufferedImage)9 GrayF32 (boofcv.struct.image.GrayF32)8 Test (org.junit.jupiter.api.Test)8 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)7 GrayU8 (boofcv.struct.image.GrayU8)7 File (java.io.File)5 Point2D_F64 (georegression.struct.point.Point2D_F64)4 Point3D_F64 (georegression.struct.point.Point3D_F64)4 RectifyCalibrated (boofcv.alg.geo.rectify.RectifyCalibrated)3 ListDisplayPanel (boofcv.gui.ListDisplayPanel)3 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)2 Planar (boofcv.struct.image.Planar)2 DMatrixRMaj (org.ejml.data.DMatrixRMaj)2 ConfigSpeckleFilter (boofcv.abst.disparity.ConfigSpeckleFilter)1 CalibrateStereoPlanar (boofcv.abst.geo.calibration.CalibrateStereoPlanar)1 CreateSyntheticOverheadViewPL (boofcv.alg.sfm.overhead.CreateSyntheticOverheadViewPL)1 SelectOverheadParameters (boofcv.alg.sfm.overhead.SelectOverheadParameters)1