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