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;
}
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);
}
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);
}
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);
}
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;
}
Aggregations