Search in sources :

Example 1 with PointToPixelTransform_F32

use of boofcv.struct.distort.PointToPixelTransform_F32 in project BoofCV by lessthanoptimal.

the class UchiyaMarkerImageTracker method setLensDistortion.

/**
 * Specify lens distortion. The ellipse will be fit to the undistorted image.
 *
 * @param distortion Distortion model.
 * @param width Input image width
 * @param height Input image height
 */
public void setLensDistortion(LensDistortionNarrowFOV distortion, int width, int height) {
    if (distortion == null) {
        ellipseDetector.setLensDistortion(null);
        intensityCheck.setTransform(null);
    } else {
        Point2Transform2_F32 pointDistToUndist = distortion.undistort_F32(true, true);
        Point2Transform2_F32 point_undist_to_dist = distortion.distort_F32(true, true);
        PixelTransform<Point2D_F32> distToUndist = new PointToPixelTransform_F32(pointDistToUndist);
        PixelTransform<Point2D_F32> undist_to_dist = new PointToPixelTransform_F32(point_undist_to_dist);
        ellipseDetector.setLensDistortion(distToUndist);
        intensityCheck.setTransform(undist_to_dist);
    }
}
Also used : PointToPixelTransform_F32(boofcv.struct.distort.PointToPixelTransform_F32) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32)

Example 2 with PointToPixelTransform_F32

use of boofcv.struct.distort.PointToPixelTransform_F32 in project BoofCV by lessthanoptimal.

the class CalibrationDetectorCircleRegularGrid method setLensDistortion.

@Override
public void setLensDistortion(@Nullable LensDistortionNarrowFOV distortion, int width, int height) {
    if (distortion == null)
        detector.getEllipseDetector().setLensDistortion(null, null);
    else {
        Point2Transform2_F32 pointDistToUndist = distortion.undistort_F32(true, true);
        Point2Transform2_F32 pointUndistToDist = distortion.distort_F32(true, true);
        PixelTransform<Point2D_F32> distToUndist = new PointToPixelTransform_F32(pointDistToUndist);
        PixelTransform<Point2D_F32> undistToDist = new PointToPixelTransform_F32(pointUndistToDist);
        detector.getEllipseDetector().setLensDistortion(distToUndist, undistToDist);
    }
}
Also used : PointToPixelTransform_F32(boofcv.struct.distort.PointToPixelTransform_F32) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32)

Example 3 with PointToPixelTransform_F32

use of boofcv.struct.distort.PointToPixelTransform_F32 in project BoofCV by lessthanoptimal.

the class SquareLocatorPatternDetectorBase method setLensDistortion.

/**
 * <p>Specifies transforms which can be used to change coordinates from distorted to undistorted and the opposite
 * coordinates. The undistorted image is never explicitly created.</p>
 *
 * @param width Input image width. Used in sanity check only.
 * @param height Input image height. Used in sanity check only.
 * @param model distortion model. Null to remove a distortion model.
 */
public void setLensDistortion(int width, int height, @Nullable LensDistortionNarrowFOV model) {
    interpolate = FactoryInterpolation.bilinearPixelS(squareDetector.getInputType(), BorderType.EXTENDED);
    if (model != null) {
        PixelTransform<Point2D_F32> distToUndist = new PointToPixelTransform_F32(model.undistort_F32(true, true));
        PixelTransform<Point2D_F32> undistToDist = new PointToPixelTransform_F32(model.distort_F32(true, true));
        squareDetector.setLensDistortion(width, height, distToUndist, undistToDist);
        // needs to sample the original image when the
        Point2Transform2_F32 u2d = model.distort_F32(true, true);
        this.interpolate = new InterpolatePixelDistortS<>(this.interpolate, u2d);
    } else {
        squareDetector.setLensDistortion(width, height, null, null);
    }
}
Also used : PointToPixelTransform_F32(boofcv.struct.distort.PointToPixelTransform_F32) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32)

Example 4 with PointToPixelTransform_F32

use of boofcv.struct.distort.PointToPixelTransform_F32 in project BoofCV by lessthanoptimal.

the class RectifyDistortImageOps method rectifyImage.

/**
 * Creates an {@link ImageDistort} for rectifying an image given its rectification matrix.
 * Lens distortion is assumed to have been previously removed.
 *
 * @param rectify Transform for rectifying the image.
 * @param imageType Type of single band image the transform is to be applied to.
 * @return ImageDistort for rectifying the image.
 */
public static <T extends ImageGray<T>> ImageDistort<T, T> rectifyImage(FMatrixRMaj rectify, BorderType borderType, Class<T> imageType) {
    boolean skip = borderType == BorderType.SKIP;
    if (skip) {
        borderType = BorderType.EXTENDED;
    }
    InterpolatePixelS<T> interp = FactoryInterpolation.bilinearPixelS(imageType, borderType);
    FMatrixRMaj rectifyInv = new FMatrixRMaj(3, 3);
    CommonOps_FDRM.invert(rectify, rectifyInv);
    PointTransformHomography_F32 rectifyTran = new PointTransformHomography_F32(rectifyInv);
    // don't bother caching the results since it is likely to only be applied once and is cheap to compute
    ImageDistort<T, T> ret = FactoryDistort.distortSB(false, interp, imageType);
    ret.setRenderAll(!skip);
    ret.setModel(new PointToPixelTransform_F32(rectifyTran));
    return ret;
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) PointTransformHomography_F32(boofcv.alg.distort.PointTransformHomography_F32) PointToPixelTransform_F32(boofcv.struct.distort.PointToPixelTransform_F32)

Example 5 with PointToPixelTransform_F32

use of boofcv.struct.distort.PointToPixelTransform_F32 in project BoofCV by lessthanoptimal.

the class CalibrationDetectorChessboardBinary method setLensDistortion.

@Override
public void setLensDistortion(@Nullable LensDistortionNarrowFOV distortion, int width, int height) {
    if (distortion == null) {
        alg.getFindSeeds().getDetectorSquare().setLensDistortion(width, height, null, null);
    } else {
        Point2Transform2_F32 pointDistToUndist = distortion.undistort_F32(true, true);
        Point2Transform2_F32 pointUndistToDist = distortion.distort_F32(true, true);
        PixelTransform<Point2D_F32> distToUndist = new PointToPixelTransform_F32(pointDistToUndist);
        PixelTransform<Point2D_F32> undistToDist = new PointToPixelTransform_F32(pointUndistToDist);
        alg.getFindSeeds().getDetectorSquare().setLensDistortion(width, height, distToUndist, undistToDist);
    }
}
Also used : PointToPixelTransform_F32(boofcv.struct.distort.PointToPixelTransform_F32) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32)

Aggregations

PointToPixelTransform_F32 (boofcv.struct.distort.PointToPixelTransform_F32)17 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)8 Point2D_F32 (georegression.struct.point.Point2D_F32)7 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)5 BufferedImage (java.awt.image.BufferedImage)5 LensDistortionPinhole (boofcv.alg.distort.pinhole.LensDistortionPinhole)3 Planar (boofcv.struct.image.Planar)3 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)2 NarrowToWidePtoP_F32 (boofcv.alg.distort.NarrowToWidePtoP_F32)2 ImagePanel (boofcv.gui.image.ImagePanel)2 FMatrixRMaj (org.ejml.data.FMatrixRMaj)2 ConfigDeformPointMLS (boofcv.abst.distort.ConfigDeformPointMLS)1 PointDeformKeyPoints (boofcv.abst.distort.PointDeformKeyPoints)1 LensDistortionWideFOV (boofcv.alg.distort.LensDistortionWideFOV)1 PointTransformHomography_F32 (boofcv.alg.distort.PointTransformHomography_F32)1 LensDistortionUniversalOmni (boofcv.alg.distort.universal.LensDistortionUniversalOmni)1 InterpolatePixelS (boofcv.alg.interpolate.InterpolatePixelS)1 ListDisplayPanel (boofcv.gui.ListDisplayPanel)1 CameraPinhole (boofcv.struct.calib.CameraPinhole)1 CameraUniversalOmni (boofcv.struct.calib.CameraUniversalOmni)1