use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.
the class TestPnPStereoResidualReprojection method compareToReprojection.
@Test
public void compareToReprojection() {
Se3_F64 worldToLeft = new Se3_F64();
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, 1, -0.2, worldToLeft.getR());
worldToLeft.getT().set(-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.rightToLeft = this.param.rightToLeft;
// intrinsic parameters are configured to be identical to normalized image coordinates
param.left = new CameraPinholeRadial(1, 1, 0, 0, 0, 0, 0).fsetRadial(0, 0);
param.right = new CameraPinholeRadial(1, 1, 0, 0, 0, 0, 0).fsetRadial(0, 0);
validation.setStereoParameters(param);
validation.setModel(worldToLeft);
double expected = validation.computeDistance(pointPose.get(0));
assertEquals(expected, found, 1e-8);
}
use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.
the class TestCalibrateStereoPlanar method fullBasic.
/**
* Give it a fake feature detector and a fairly benign scenario and see if it can correctly
* estimate the camera parameters.
*/
@Test
public void fullBasic() {
CalibrateStereoPlanar alg = new CalibrateStereoPlanar(layout);
alg.configure(true, 2, true);
for (int i = 0; i < targetToLeft.size(); i++) {
alg.addPair(createFakeObservations(i, true), createFakeObservations(i, false));
}
StereoParameters found = alg.process();
checkIntrinsic(found.left);
checkIntrinsic(found.right);
Se3_F64 rightToLeft = found.getRightToLeft();
Se3_F64 expected = leftToRight.invert(null);
assertEquals(0, expected.getT().distance(rightToLeft.T), 1.01e-3);
assertTrue(MatrixFeatures_DDRM.isIdentity(rightToLeft.getR(), 1e-3));
}
use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.
the class CheckVisualOdometryStereoSim method changeInputSize.
@Test
public 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.setCalibration(paramSmall);
algorithm.process(leftSmall, rightSmall);
StereoParameters paramLarge = createStereoParam();
paramLarge.left.width = paramLarge.right.width = leftLarge.width;
paramLarge.left.height = paramLarge.right.height = leftLarge.height;
algorithm.setCalibration(paramLarge);
algorithm.process(leftLarge, rightSmall);
}
use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.
the class TestStereoVisualOdometryScaleInput method process.
@Test
public void process() {
StereoParameters p = createStereoParam();
Dummy dummy = new Dummy();
StereoVisualOdometryScaleInput<GrayF32> alg = new StereoVisualOdometryScaleInput<>(dummy, 0.5);
alg.setCalibration(p);
GrayF32 left = new GrayF32(width, height);
GrayF32 right = new GrayF32(width, height);
alg.process(left, right);
assertTrue(left != leftImage);
assertTrue(right != rightImage);
assertEquals(320, leftImage.width);
assertEquals(320, rightImage.width);
assertEquals(160, leftImage.height);
assertEquals(160, rightImage.height);
}
use of boofcv.struct.calib.StereoParameters in project BoofCV by lessthanoptimal.
the class TestStereoVisualOdometryScaleInput method getImageType.
@Test
public void getImageType() {
StereoParameters p = createStereoParam();
Dummy dummy = new Dummy();
StereoVisualOdometryScaleInput<GrayF32> alg = new StereoVisualOdometryScaleInput<>(dummy, 0.5);
assertTrue(type == alg.getImageType());
}
Aggregations