Search in sources :

Example 11 with PointToPixelTransform_F32

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

the class DisplayFisheyeCalibrationPanel method setPinholeCenter.

public void setPinholeCenter(double pixelX, double pixelY) {
    this.pixelX = pixelX;
    this.pixelY = pixelY;
    var norm = new Point3D_F32();
    Objects.requireNonNull(fisheyeDistort);
    fisheyeDistort.undistortPtoS_F32().compute((float) pixelX, (float) pixelY, norm);
    var rotation = new Rodrigues_F32();
    var canonical = new Vector3D_F32(0, 0, 1);
    rotation.theta = UtilVector3D_F32.acute(new Vector3D_F32(norm), canonical);
    GeometryMath_F32.cross(canonical, norm, rotation.unitAxisRotation);
    rotation.unitAxisRotation.normalize();
    FMatrixRMaj R = ConvertRotation3D_F32.rodriguesToMatrix(rotation, null);
    Objects.requireNonNull(distorter);
    distorter.setRotationWideToNarrow(R);
    distortImage.setModel(new PointToPixelTransform_F32(distorter));
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) Vector3D_F32(georegression.struct.point.Vector3D_F32) UtilVector3D_F32(georegression.geometry.UtilVector3D_F32) FMatrixRMaj(org.ejml.data.FMatrixRMaj) Rodrigues_F32(georegression.struct.so.Rodrigues_F32) PointToPixelTransform_F32(boofcv.struct.distort.PointToPixelTransform_F32)

Example 12 with PointToPixelTransform_F32

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

the class DisplayFisheyeCalibrationPanel method setCalibration.

public void setCalibration(LensDistortionWideFOV fisheyeDistort, int width, int height) {
    BoofSwingUtil.checkGuiThread();
    this.fisheyeDistort = fisheyeDistort;
    LensDistortionNarrowFOV pinholeDistort = new LensDistortionPinhole(pinholeModel);
    distorter = new NarrowToWidePtoP_F32(pinholeDistort, fisheyeDistort);
    // Create the image distorter which will render the image
    InterpolatePixel<Planar<GrayF32>> interp = FactoryInterpolation.createPixel(0, 255, InterpolationType.BILINEAR, BorderType.ZERO, imageFisheye.getImageType());
    distortImage = FactoryDistort.distort(false, interp, imageFisheye.getImageType());
    // Pass in the transform created above
    distortImage.setModel(new PointToPixelTransform_F32(distorter));
    setPinholeCenter(width / 2, height / 2);
    renderPinhole();
}
Also used : LensDistortionPinhole(boofcv.alg.distort.pinhole.LensDistortionPinhole) LensDistortionNarrowFOV(boofcv.alg.distort.LensDistortionNarrowFOV) PointToPixelTransform_F32(boofcv.struct.distort.PointToPixelTransform_F32) Planar(boofcv.struct.image.Planar) NarrowToWidePtoP_F32(boofcv.alg.distort.NarrowToWidePtoP_F32)

Example 13 with PointToPixelTransform_F32

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

the class CalibrationDetectorSquareGrid method setLensDistortion.

@Override
public void setLensDistortion(@Nullable LensDistortionNarrowFOV distortion, int width, int height) {
    if (distortion == null)
        detector.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);
        detector.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)

Example 14 with PointToPixelTransform_F32

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

the class FisheyePinholeApp method updatedPinholeModel.

@Override
public void updatedPinholeModel(int width, int height, double fov) {
    final boolean shapeChanged = camWidth != width || camHeight != height;
    this.camWidth = width;
    this.camHeight = height;
    this.hfov = fov;
    synchronized (imageLock) {
        if (shapeChanged) {
            panelPinhole.setPreferredSize(new Dimension(camWidth, camHeight));
            pinhole.reshape(camWidth, camHeight);
            buffPinhole = new BufferedImage(camWidth, camHeight, BufferedImage.TYPE_INT_BGR);
        }
        updateIntrinsic();
        distorter.configure(new LensDistortionPinhole(cameraModel), fisheyeDistort);
        distortImage.setModel(new PointToPixelTransform_F32(distorter));
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                if (shapeChanged) {
                    panelPinhole.setPreferredSize(new Dimension(camWidth, camHeight));
                    panelPinhole.setMinimumSize(new Dimension(camWidth, camHeight));
                    panelPinhole.setMaximumSize(new Dimension(camWidth, camHeight));
                    imageView.setDividerLocation(-1);
                }
            }
        });
        if (inputMethod == InputMethod.IMAGE) {
            rerenderPinhole();
        }
    }
}
Also used : LensDistortionPinhole(boofcv.alg.distort.pinhole.LensDistortionPinhole) PointToPixelTransform_F32(boofcv.struct.distort.PointToPixelTransform_F32) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 15 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 radial distortion and
 * rectification matrix.
 *
 * @param param Intrinsic parameters.
 * @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 ImageBase<T>> ImageDistort<T, T> rectifyImage(CameraPinholeBrown param, FMatrixRMaj rectify, BorderType borderType, ImageType<T> imageType) {
    boolean skip = borderType == BorderType.SKIP;
    if (skip) {
        borderType = BorderType.EXTENDED;
    }
    InterpolatePixel<T> interp = FactoryInterpolation.createPixel(0, 255, InterpolationType.BILINEAR, borderType, imageType);
    // only compute the transform once
    ImageDistort<T, T> ret = FactoryDistort.distort(true, interp, imageType);
    ret.setRenderAll(!skip);
    Point2Transform2_F32 transform = RectifyImageOps.transformRectToPixel(param, rectify);
    ret.setModel(new PointToPixelTransform_F32(transform));
    return ret;
}
Also used : PointToPixelTransform_F32(boofcv.struct.distort.PointToPixelTransform_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