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