Search in sources :

Example 66 with CameraPinholeBrown

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

the class RemoveLensDistortionApp method openFile.

@Override
public void openFile(File file) {
    File[] candidates = new File[] { new File(file.getParent(), "intrinsic.yaml"), // this is a bit of a hack...
    new File(file.getParent(), "intrinsicLeft.yaml"), new File(file.getParent(), file.getName() + ".yaml") };
    CameraPinholeBrown model = null;
    for (File c : candidates) {
        try {
            model = CalibrationIO.load(UtilIO.ensureURL(c.getPath()));
            break;
        } catch (RuntimeException ignore) {
        }
    }
    if (model == null) {
        System.err.println("Can't find camera model for this image");
        return;
    }
    this.param = model;
    super.openFile(file);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) File(java.io.File)

Example 67 with CameraPinholeBrown

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

the class TestCameraToEquirectangular_F64 method canonicalIsPointedPositiveZ.

/**
 * Makes sure the canonical orientation is pointed along the positive z axis. This is done by projecting
 * the center of the pinhole at default orientation.
 */
@Test
void canonicalIsPointedPositiveZ() {
    CameraPinholeBrown intrinsic = new CameraPinholeBrown(400, 400, 0, imgWidth / 2, imgHeight / 2, imgWidth, imgHeight);
    intrinsic.setRadial(0.1, 0.2);
    CameraToEquirectangular_F64 alg = new CameraToEquirectangular_F64();
    alg.setCameraModel(intrinsic);
    alg.setEquirectangularShape(equiWidth, equiHeight);
    assertPointing(alg, imgWidth / 2, imgHeight / 2, 0, 0, 1);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Test(org.junit.jupiter.api.Test)

Example 68 with CameraPinholeBrown

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

the class TestLensDistortionOps_F64 method transformChangeModel_EXPAND_modified.

/**
 * Sees if the adjusted intrinsic parameters is correct but computing normalized image coordinates first
 * with the original distorted image and then with the adjusted undistorted image.
 */
@Test
void transformChangeModel_EXPAND_modified() {
    // distorted pixel in original image
    double pixelX = 12.5, pixelY = height - 3;
    CameraPinholeBrown orig = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
    CameraPinhole desired = new CameraPinhole(orig);
    Point2Transform2_F64 distToNorm = LensDistortionFactory.narrow(orig).undistort_F64(true, false);
    Point2D_F64 norm = new Point2D_F64();
    distToNorm.compute(pixelX, pixelY, norm);
    CameraPinholeBrown adjusted = new CameraPinholeBrown();
    Point2Transform2_F64 distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.EXPAND, orig, desired, false, adjusted);
    Point2D_F64 adjPixel = new Point2D_F64();
    Point2D_F64 normFound = new Point2D_F64();
    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 : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 69 with CameraPinholeBrown

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

the class TestLensDistortionOps_F64 method transformChangeModel_FULLVIEW_modified.

/**
 * Checks to see if the returned modified model is correct
 */
@Test
void transformChangeModel_FULLVIEW_modified() {
    // distorted pixel in original image
    double pixelX = 12.5, pixelY = height - 3;
    CameraPinholeBrown orig = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
    CameraPinhole desired = new CameraPinhole(orig);
    Point2Transform2_F64 distToNorm = LensDistortionFactory.narrow(orig).undistort_F64(true, false);
    Point2D_F64 norm = new Point2D_F64();
    distToNorm.compute(pixelX, pixelY, norm);
    CameraPinholeBrown adjusted = new CameraPinholeBrown();
    Point2Transform2_F64 distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.FULL_VIEW, orig, desired, false, adjusted);
    Point2D_F64 adjPixel = new Point2D_F64();
    Point2D_F64 normFound = new Point2D_F64();
    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 : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

Example 70 with CameraPinholeBrown

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

the class TestLensDistortionOps_F64 method transformChangeModel_FULLVIEW.

/**
 * Checks the border of the returned transform. Makes sure that the entire original image is visible.
 * Also makes sure that the requested inverse transform is actually the inverse.
 */
@Test
void transformChangeModel_FULLVIEW() {
    CameraPinholeBrown param = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 0.05);
    CameraPinhole desired = new CameraPinhole(param);
    Point2Transform2_F64 adjToDist = LensDistortionOps_F64.transformChangeModel(AdjustmentType.FULL_VIEW, param, desired, true, null);
    Point2Transform2_F64 distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.FULL_VIEW, param, desired, false, null);
    checkBorderOutside(adjToDist, distToAdj);
    param = new CameraPinholeBrown().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(-0.1, -0.05);
    desired = new CameraPinhole(param);
    adjToDist = LensDistortionOps_F64.transformChangeModel(AdjustmentType.FULL_VIEW, param, desired, true, null);
    distToAdj = LensDistortionOps_F64.transformChangeModel(AdjustmentType.FULL_VIEW, param, desired, false, null);
    checkBorderOutside(adjToDist, distToAdj);
}
Also used : CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) CameraPinhole(boofcv.struct.calib.CameraPinhole) Test(org.junit.jupiter.api.Test)

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