Search in sources :

Example 81 with CameraPinhole

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);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.Test)

Example 82 with CameraPinhole

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);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.Test)

Example 83 with CameraPinhole

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);
}
Also used : SequencePoint2Transform2_F32(boofcv.struct.distort.SequencePoint2Transform2_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) SequencePoint2Transform2_F32(boofcv.struct.distort.SequencePoint2Transform2_F32) CameraPinhole(boofcv.struct.calib.CameraPinhole) PixelTransform2_F32(boofcv.struct.distort.PixelTransform2_F32) PixelTransformCached_F32(boofcv.alg.distort.PixelTransformCached_F32)

Example 84 with CameraPinhole

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);
}
Also used : CameraPinhole(boofcv.struct.calib.CameraPinhole)

Example 85 with CameraPinhole

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));
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) CameraPinhole(boofcv.struct.calib.CameraPinhole) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Aggregations

CameraPinhole (boofcv.struct.calib.CameraPinhole)154 Test (org.junit.jupiter.api.Test)81 Se3_F64 (georegression.struct.se.Se3_F64)36 DMatrixRMaj (org.ejml.data.DMatrixRMaj)32 Point2D_F64 (georegression.struct.point.Point2D_F64)24 ArrayList (java.util.ArrayList)23 Point3D_F64 (georegression.struct.point.Point3D_F64)19 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)12 SceneStructureMetric (boofcv.abst.geo.bundle.SceneStructureMetric)11 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)11 Test (org.junit.Test)10 GrayF32 (boofcv.struct.image.GrayF32)9 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)8 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)8 BufferedImage (java.awt.image.BufferedImage)8 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)7 VerbosePrint (org.ddogleg.struct.VerbosePrint)7 LensDistortionPinhole (boofcv.alg.distort.pinhole.LensDistortionPinhole)6 WorldToCameraToPixel (boofcv.alg.geo.WorldToCameraToPixel)6 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)5