use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestLensDistortionOps method transformChangeModel_F32_FULLVIEW_modified.
/**
* Checks to see if the returned modified model is correct
*/
@Test
public void transformChangeModel_F32_FULLVIEW_modified() {
// distorted pixel in original image
float pixelX = 12.5f, pixelY = height - 3;
CameraPinholeRadial orig = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
CameraPinhole desired = new CameraPinhole(orig);
Point2Transform2_F32 distToNorm = LensDistortionOps.narrow(orig).undistort_F32(true, false);
Point2D_F32 norm = new Point2D_F32();
distToNorm.compute(pixelX, pixelY, norm);
CameraPinholeRadial adjusted = new CameraPinholeRadial();
Point2Transform2_F32 distToAdj = LensDistortionOps.transformChangeModel_F32(AdjustmentType.FULL_VIEW, orig, desired, false, adjusted);
Point2D_F32 adjPixel = new Point2D_F32();
Point2D_F32 normFound = new Point2D_F32();
distToAdj.compute(pixelX, pixelY, adjPixel);
PerspectiveOps.convertPixelToNorm(adjusted, adjPixel, normFound);
// see if the normalized image coordinates are the same
assertEquals(norm.x, normFound.x, 1e-3);
assertEquals(norm.y, normFound.y, 1e-3);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestLensDistortionOps method transformChangeModel_F32_NONE_modified.
@Test
public void transformChangeModel_F32_NONE_modified() {
// distorted pixel in original image
float pixelX = 12.5f, pixelY = height - 3;
CameraPinholeRadial orig = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
CameraPinhole desired = new CameraPinhole(orig);
Point2Transform2_F32 distToNorm = LensDistortionOps.narrow(orig).undistort_F32(true, false);
Point2D_F32 norm = new Point2D_F32();
distToNorm.compute(pixelX, pixelY, norm);
CameraPinhole adjusted = new CameraPinhole();
Point2Transform2_F32 distToAdj = LensDistortionOps.transformChangeModel_F32(AdjustmentType.NONE, orig, desired, false, adjusted);
Point2D_F32 adjPixel = new Point2D_F32();
Point2D_F32 normFound = new Point2D_F32();
distToAdj.compute(pixelX, pixelY, adjPixel);
PerspectiveOps.convertPixelToNorm(adjusted, adjPixel, normFound);
// see if the normalized image coordinates are the same
assertEquals(norm.x, normFound.x, 1e-3);
assertEquals(norm.y, normFound.y, 1e-3);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class PyramidDirectColorDepth_to_DepthVisualOdometry method setCalibration.
@Override
public void setCalibration(CameraPinholeRadial paramVisual, Point2Transform2_F32 visToDepth) {
// the algorithms camera model assumes no lens distortion and that skew = 0
CameraPinhole desired = new CameraPinhole(paramVisual);
desired.skew = 0;
adjustImage = LensDistortionOps.changeCameraModel(AdjustmentType.EXPAND, BorderType.ZERO, paramVisual, desired, paramAdjusted, algType);
Point2Transform2_F32 desiredToOriginal = LensDistortionOps.transformChangeModel_F32(AdjustmentType.EXPAND, paramVisual, desired, false, null);
// the adjusted undistorted image pixel to the depth image transform
Point2Transform2_F32 adjustedToDepth = new SequencePoint2Transform2_F32(desiredToOriginal, visToDepth);
// Create a lookup table to make the math much faster
PixelTransform2_F32 pixelAdjToDepth = new PixelTransformCached_F32(paramAdjusted.width, paramAdjusted.height, adjustedToDepth);
// adjusted pixels to normalized image coordinates in RGB frame
sparse3D.configure(LensDistortionOps.narrow(paramAdjusted), pixelAdjToDepth);
undistorted.reshape(paramAdjusted.width, paramAdjusted.height);
if (convertInput != null) {
inputConverted.reshape(paramAdjusted.width, paramAdjusted.height);
}
alg.setCameraParameters((float) paramAdjusted.fx, (float) paramAdjusted.fy, (float) paramAdjusted.cx, (float) paramAdjusted.cy, paramAdjusted.width, paramAdjusted.height);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class DisplayPinholeCalibrationPanel method setCalibration.
public void setCalibration(CameraPinholeBrown param) {
CameraPinhole undistorted = new CameraPinhole(param);
this.undoRadial = LensDistortionOps.changeCameraModel(AdjustmentType.FULL_VIEW, BorderType.ZERO, param, undistorted, null, ImageType.single(GrayF32.class));
this.remove_p_to_p = LensDistortionOps_F32.transformChangeModel(AdjustmentType.FULL_VIEW, param, undistorted, false, null);
undoRadialDistortion(distorted);
}
use of boofcv.struct.calib.CameraPinhole in project BoofCV by lessthanoptimal.
the class TestPRnPDirectLinearTransform method minimal_perfect.
/**
* No noise minimal case. General structure
*/
@Test
void minimal_perfect() {
Se3_F64 m = SpecialEuclideanOps_F64.eulerXyz(0.01, 0.1, 1, 0.01, -0.02, 0.015, null);
DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(new CameraPinhole(500, 500, 0, 250, 250, 1000, 1000), (DMatrixRMaj) null);
PRnPDirectLinearTransform alg = new PRnPDirectLinearTransform();
DMatrixRMaj P = PerspectiveOps.createCameraMatrix(m.R, m.T, K, null);
generateScene(alg.getMinimumPoints(), P, false);
DMatrixRMaj found = new DMatrixRMaj(3, 4);
assertTrue(alg.process(worldPts, pixelsView2, found));
CommonOps_DDRM.divide(P, NormOps_DDRM.normF(P));
CommonOps_DDRM.divide(found, NormOps_DDRM.normF(found));
if (Math.signum(P.get(0, 0)) != Math.signum(found.get(0, 0))) {
CommonOps_DDRM.scale(-1, found);
}
assertTrue(MatrixFeatures_DDRM.isIdentical(P, found, UtilEjml.TEST_F64));
}
Aggregations