Search in sources :

Example 1 with PointTransformHomography_F32

use of boofcv.alg.distort.PointTransformHomography_F32 in project BoofCV by lessthanoptimal.

the class RectifyImageOps 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.alg.distort.PointToPixelTransform_F32)

Example 2 with PointTransformHomography_F32

use of boofcv.alg.distort.PointTransformHomography_F32 in project BoofCV by lessthanoptimal.

the class ImplRectifyImageOps_F32 method transformPixelToRectNorm.

public static Point2Transform2_F32 transformPixelToRectNorm(CameraPinholeRadial param, FMatrixRMaj rectify, FMatrixRMaj rectifyK) {
    if (rectifyK.get(0, 1) != 0)
        throw new IllegalArgumentException("Skew should be zero in rectified images");
    Point2Transform2_F32 remove_p_to_p = narrow(param).undistort_F32(true, true);
    PointTransformHomography_F32 rectifyDistort = new PointTransformHomography_F32(rectify);
    PinholePtoN_F32 pixelToNorm = new PinholePtoN_F32();
    pixelToNorm.set(rectifyK.get(0, 0), rectifyK.get(1, 1), rectifyK.get(0, 1), rectifyK.get(0, 2), rectifyK.get(1, 2));
    return new SequencePoint2Transform2_F32(remove_p_to_p, rectifyDistort, pixelToNorm);
}
Also used : PointTransformHomography_F32(boofcv.alg.distort.PointTransformHomography_F32) PinholePtoN_F32(boofcv.alg.distort.pinhole.PinholePtoN_F32) SequencePoint2Transform2_F32(boofcv.struct.distort.SequencePoint2Transform2_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) SequencePoint2Transform2_F32(boofcv.struct.distort.SequencePoint2Transform2_F32)

Example 3 with PointTransformHomography_F32

use of boofcv.alg.distort.PointTransformHomography_F32 in project BoofCV by lessthanoptimal.

the class ImplRectifyImageOps_F32 method allInsideLeft.

public static void allInsideLeft(int imageWidth, int imageHeight, FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight) {
    PointTransformHomography_F32 tranLeft = new PointTransformHomography_F32(rectifyLeft);
    RectangleLength2D_F32 bound = LensDistortionOps.boundBoxInside(imageWidth, imageHeight, new PointToPixelTransform_F32(tranLeft));
    float scaleX = imageWidth / (float) bound.width;
    float scaleY = imageHeight / (float) bound.height;
    float scale = (float) Math.max(scaleX, scaleY);
    adjustUncalibrated(rectifyLeft, rectifyRight, bound, scale);
}
Also used : PointTransformHomography_F32(boofcv.alg.distort.PointTransformHomography_F32) PointToPixelTransform_F32(boofcv.alg.distort.PointToPixelTransform_F32) RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32)

Example 4 with PointTransformHomography_F32

use of boofcv.alg.distort.PointTransformHomography_F32 in project BoofCV by lessthanoptimal.

the class ImplRectifyImageOps_F32 method transformRectToPixel.

public static Point2Transform2_F32 transformRectToPixel(CameraPinholeRadial param, FMatrixRMaj rectify) {
    Point2Transform2_F32 add_p_to_p = narrow(param).distort_F32(true, true);
    FMatrixRMaj rectifyInv = new FMatrixRMaj(3, 3);
    CommonOps_FDRM.invert(rectify, rectifyInv);
    PointTransformHomography_F32 removeRect = new PointTransformHomography_F32(rectifyInv);
    return new SequencePoint2Transform2_F32(removeRect, add_p_to_p);
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) PointTransformHomography_F32(boofcv.alg.distort.PointTransformHomography_F32) SequencePoint2Transform2_F32(boofcv.struct.distort.SequencePoint2Transform2_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) SequencePoint2Transform2_F32(boofcv.struct.distort.SequencePoint2Transform2_F32)

Example 5 with PointTransformHomography_F32

use of boofcv.alg.distort.PointTransformHomography_F32 in project BoofCV by lessthanoptimal.

the class TestBackgroundMovingGaussian_IL method create.

@Override
public <T extends ImageBase<T>> BackgroundModelMoving<T, Homography2D_F32> create(ImageType<T> imageType) {
    PointTransformHomography_F32 transform = new PointTransformHomography_F32();
    BackgroundMovingGaussian_IL alg = new BackgroundMovingGaussian_IL(0.05f, 16, transform, InterpolationType.BILINEAR, imageType);
    alg.setInitialVariance(12);
    return alg;
}
Also used : PointTransformHomography_F32(boofcv.alg.distort.PointTransformHomography_F32)

Aggregations

PointTransformHomography_F32 (boofcv.alg.distort.PointTransformHomography_F32)13 FMatrixRMaj (org.ejml.data.FMatrixRMaj)5 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)4 SequencePoint2Transform2_F32 (boofcv.struct.distort.SequencePoint2Transform2_F32)4 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)3 RectangleLength2D_F32 (georegression.struct.shapes.RectangleLength2D_F32)2 Test (org.junit.Test)2 ConfigPointDetector (boofcv.abst.feature.detect.interest.ConfigPointDetector)1 PointTracker (boofcv.abst.tracker.PointTracker)1 BackgroundModelMoving (boofcv.alg.background.BackgroundModelMoving)1 PinholePtoN_F32 (boofcv.alg.distort.pinhole.PinholePtoN_F32)1 ConfigBackgroundBasic (boofcv.factory.background.ConfigBackgroundBasic)1 ConfigBackgroundGaussian (boofcv.factory.background.ConfigBackgroundGaussian)1 ConfigBackgroundGmm (boofcv.factory.background.ConfigBackgroundGmm)1 FactoryPointTracker (boofcv.factory.tracker.FactoryPointTracker)1 ImageGridPanel (boofcv.gui.image.ImageGridPanel)1 MediaManager (boofcv.io.MediaManager)1 SimpleImageSequence (boofcv.io.image.SimpleImageSequence)1 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)1 PointToPixelTransform_F32 (boofcv.struct.distort.PointToPixelTransform_F32)1