use of boofcv.alg.distort.universal.LensDistortionUniversalOmni in project BoofCV by lessthanoptimal.
the class TestNarrowToWidePtoP_F64 method createModelWide.
public static LensDistortionWideFOV createModelWide() {
CameraUniversalOmni model = new CameraUniversalOmni(2);
model.fsetK(1.349e3, 1.343e3, 0, 480, 480, 960, 1080);
model.fsetMirror(3.61);
model.fsetRadial(7.308e-1, 1.855e1);
model.fsetTangental(-1.288e-2, -1.1342e-2);
return new LensDistortionUniversalOmni(model);
}
use of boofcv.alg.distort.universal.LensDistortionUniversalOmni in project BoofCV by lessthanoptimal.
the class FisheyePinholeApp method openFile.
@Override
public void openFile(File file) {
File intrinsicFile = new File(file.getParent(), "front.yaml");
CameraUniversalOmni fisheyeModel = CalibrationIO.load(intrinsicFile);
fisheyeDistort = new LensDistortionUniversalOmni(fisheyeModel);
distorter.configure(new LensDistortionPinhole(cameraModel), fisheyeDistort);
super.openFile(file);
}
use of boofcv.alg.distort.universal.LensDistortionUniversalOmni in project BoofCV by lessthanoptimal.
the class ExampleFisheyeToEquirectangular method main.
public static void main(String[] args) {
// Path to image data and calibration data
String fisheyePath = UtilIO.pathExample("fisheye/theta");
// load the fisheye camera parameters
CameraUniversalOmni model0 = CalibrationIO.load(new File(fisheyePath, "front.yaml"));
CameraUniversalOmni model1 = CalibrationIO.load(new File(fisheyePath, "back.yaml"));
LensDistortionWideFOV distort0 = new LensDistortionUniversalOmni(model0);
LensDistortionWideFOV distort1 = new LensDistortionUniversalOmni(model1);
ImageType<Planar<GrayF32>> imageType = ImageType.pl(3, GrayF32.class);
InterpolatePixel<Planar<GrayF32>> interp = FactoryInterpolation.createPixel(0, 255, InterpolationType.BILINEAR, BorderType.ZERO, imageType);
ImageDistort<Planar<GrayF32>, Planar<GrayF32>> distort = FactoryDistort.distort(false, interp, imageType);
// This will create an equirectangular image with 800 x 400 pixels
MultiCameraToEquirectangular<Planar<GrayF32>> alg = new MultiCameraToEquirectangular<>(distort, 800, 400, imageType);
// this is an important parameter and is used to filter out falsely mirrored pixels
alg.setMaskToleranceAngle(UtilAngle.radian(0.1f));
// camera has a known FOV of 185 degrees
GrayU8 mask0 = createMask(model0, distort0, UtilAngle.radian(182));
// the edges are likely to be noisy,
GrayU8 mask1 = createMask(model1, distort1, UtilAngle.radian(182));
// so crop it a bit..
// Rotate camera axis so that +x is forward and not +z and make it visually pleasing
FMatrixRMaj adjR = ConvertRotation3D_F32.eulerToMatrix(EulerType.XYZ, GrlConstants.F_PI / 2, 0, 0, null);
// Rotation from the front camera to the back facing camera.
// This is only an approximation. Should be determined through calibration.
FMatrixRMaj f2b = ConvertRotation3D_F32.eulerToMatrix(EulerType.ZYX, GrlConstants.F_PI, 0, 0, null);
Se3_F32 frontToFront = new Se3_F32();
frontToFront.setRotation(adjR);
Se3_F32 frontToBack = new Se3_F32();
CommonOps_FDRM.mult(f2b, adjR, frontToBack.R);
// add the camera and specify which pixels are valid. These functions precompute the entire transform
// and can be relatively slow, but generating the equirectangular image should be much faster
alg.addCamera(frontToBack, distort0, mask0);
alg.addCamera(frontToFront, distort1, mask1);
// Load fisheye RGB image
BufferedImage buffered0 = UtilImageIO.loadImage(fisheyePath, "front_table.jpg");
Planar<GrayF32> fisheye0 = ConvertBufferedImage.convertFrom(buffered0, true, ImageType.pl(3, GrayF32.class));
BufferedImage buffered1 = UtilImageIO.loadImage(fisheyePath, "back_table.jpg");
Planar<GrayF32> fisheye1 = ConvertBufferedImage.convertFrom(buffered1, true, ImageType.pl(3, GrayF32.class));
List<Planar<GrayF32>> images = new ArrayList<>();
images.add(fisheye0);
images.add(fisheye1);
alg.render(images);
BufferedImage equiOut = ConvertBufferedImage.convertTo(alg.getRenderedImage(), null, true);
ShowImages.showWindow(equiOut, "Dual Fisheye to Equirectangular", true);
}
use of boofcv.alg.distort.universal.LensDistortionUniversalOmni in project BoofCV by lessthanoptimal.
the class ExampleFisheyeToPinhole method main.
public static void main(String[] args) {
// Path to image data and calibration data
String fisheyePath = UtilIO.pathExample("fisheye/theta/");
// load the fisheye camera parameters
CameraUniversalOmni fisheyeModel = CalibrationIO.load(new File(fisheyePath, "front.yaml"));
// Specify what the pinhole camera should look like
CameraPinhole pinholeModel = new CameraPinhole(400, 400, 0, 300, 300, 600, 600);
// Create the transform from pinhole to fisheye views
LensDistortionNarrowFOV pinholeDistort = new LensDistortionPinhole(pinholeModel);
LensDistortionWideFOV fisheyeDistort = new LensDistortionUniversalOmni(fisheyeModel);
NarrowToWidePtoP_F32 transform = new NarrowToWidePtoP_F32(pinholeDistort, fisheyeDistort);
// Load fisheye RGB image
BufferedImage bufferedFisheye = UtilImageIO.loadImage(fisheyePath, "front_table.jpg");
Planar<GrayU8> fisheyeImage = ConvertBufferedImage.convertFrom(bufferedFisheye, true, ImageType.pl(3, GrayU8.class));
// Create the image distorter which will render the image
InterpolatePixel<Planar<GrayU8>> interp = FactoryInterpolation.createPixel(0, 255, InterpolationType.BILINEAR, BorderType.ZERO, fisheyeImage.getImageType());
ImageDistort<Planar<GrayU8>, Planar<GrayU8>> distorter = FactoryDistort.distort(false, interp, fisheyeImage.getImageType());
// Pass in the transform created above
distorter.setModel(new PointToPixelTransform_F32(transform));
// Render the image. The camera will have a rotation of 0 and will thus be looking straight forward
Planar<GrayU8> pinholeImage = fisheyeImage.createNew(pinholeModel.width, pinholeModel.height);
distorter.apply(fisheyeImage, pinholeImage);
BufferedImage bufferedPinhole0 = ConvertBufferedImage.convertTo(pinholeImage, null, true);
// rotate the virtual pinhole camera to the right
transform.setRotationWideToNarrow(ConvertRotation3D_F32.eulerToMatrix(EulerType.YXZ, 0.8f, 0, 0, null));
distorter.apply(fisheyeImage, pinholeImage);
BufferedImage bufferedPinhole1 = ConvertBufferedImage.convertTo(pinholeImage, null, true);
// Display the results
ListDisplayPanel panel = new ListDisplayPanel();
panel.addImage(bufferedPinhole0, "Pinehole Forward");
panel.addImage(bufferedPinhole1, "Pinehole Right");
panel.addImage(bufferedFisheye, "Fisheye");
panel.setPreferredSize(new Dimension(600, 450));
ShowImages.showWindow(panel, "Fisheye to Pinhole", true);
}
use of boofcv.alg.distort.universal.LensDistortionUniversalOmni in project BoofCV by lessthanoptimal.
the class SimulatePlanarWorld method setCamera.
public void setCamera(CameraUniversalOmni model) {
output.reshape(model.width, model.height);
depthMap.reshape(model.width, model.height);
LensDistortionWideFOV factory = new LensDistortionUniversalOmni(model);
pixelTo3 = factory.undistortPtoS_F64();
sphereToPixel = factory.distortStoP_F64();
computeProjectionTable(model);
}
Aggregations