use of boofcv.struct.distort.DoNothing2Transform2_F64 in project BoofCV by lessthanoptimal.
the class ExampleStereoTwoViewsOneCamera method showPointCloud.
/**
* Show results as a point cloud
*/
public static void showPointCloud(ImageGray disparity, BufferedImage left, Se3_F64 motion, DMatrixRMaj rectifiedK, DMatrixRMaj rectifiedR, int disparityMin, int disparityRange) {
DisparityToColorPointCloud d2c = new DisparityToColorPointCloud();
PointCloudWriter.CloudArraysF32 cloud = new PointCloudWriter.CloudArraysF32();
double baseline = motion.getT().norm();
d2c.configure(baseline, rectifiedK, rectifiedR, new DoNothing2Transform2_F64(), disparityMin, disparityRange);
d2c.process(disparity, UtilDisparitySwing.wrap(left), cloud);
CameraPinhole rectifiedPinhole = PerspectiveOps.matrixToPinhole(rectifiedK, disparity.width, disparity.height, null);
// skew the view to make the structure easier to see
Se3_F64 cameraToWorld = SpecialEuclideanOps_F64.eulerXyz(-baseline * 5, 0, 0, 0, 0.2, 0, null);
PointCloudViewer pcv = VisualizeData.createPointCloudViewer();
pcv.setCameraHFov(PerspectiveOps.computeHFov(rectifiedPinhole));
pcv.setCameraToWorld(cameraToWorld);
pcv.setTranslationStep(baseline / 3);
pcv.addCloud(cloud.cloudXyz, cloud.cloudRgb);
pcv.setDotSize(1);
pcv.setTranslationStep(baseline / 10);
pcv.getComponent().setPreferredSize(new Dimension(left.getWidth(), left.getHeight()));
ShowImages.showWindow(pcv.getComponent(), "Point Cloud", true);
}
use of boofcv.struct.distort.DoNothing2Transform2_F64 in project BoofCV by lessthanoptimal.
the class VisualizeStereoDisparity method rectifyInputImages.
/**
* Removes distortion and rectifies images.
*/
private void rectifyInputImages() {
// Check to see if the input images have already been recitified
rectifiedImages = calib.isRectified(1e-3);
// get intrinsic camera calibration matrices
DMatrixRMaj K1 = PerspectiveOps.pinholeToMatrix(calib.left, (DMatrixRMaj) null);
DMatrixRMaj K2 = PerspectiveOps.pinholeToMatrix(calib.right, (DMatrixRMaj) null);
// and could add a little bit of noise
if (rectifiedImages) {
rectLeft.setTo(inputLeft);
rectRight.setTo(inputRight);
leftRectToPixel = new DoNothing2Transform2_F64();
rectK = K1;
rectR = CommonOps_DDRM.identity(3);
return;
}
// compute rectification matrices
rectifyAlg.process(K1, new Se3_F64(), K2, calib.getRightToLeft().invert(null));
DMatrixRMaj rect1 = rectifyAlg.getUndistToRectPixels1();
DMatrixRMaj rect2 = rectifyAlg.getUndistToRectPixels2();
rectK = rectifyAlg.getCalibrationMatrix();
rectR = rectifyAlg.getRectifiedRotation();
// adjust view to maximize viewing area while not including black regions
RectifyImageOps.allInsideLeft(calib.left, rect1, rect2, rectK, null);
// compute transforms to apply rectify the images
leftRectToPixel = transformRectToPixel(calib.left, rect1);
ImageType<T> imageType = activeAlg.getInputType();
// TODO simplify code some how
FMatrixRMaj rect1_F32 = new FMatrixRMaj(3, 3);
FMatrixRMaj rect2_F32 = new FMatrixRMaj(3, 3);
ConvertMatrixData.convert(rect1, rect1_F32);
ConvertMatrixData.convert(rect2, rect2_F32);
ImageDistort<T, T> distortRect1 = RectifyDistortImageOps.rectifyImage(calib.left, rect1_F32, BorderType.EXTENDED, imageType);
ImageDistort<T, T> distortRect2 = RectifyDistortImageOps.rectifyImage(calib.right, rect2_F32, BorderType.EXTENDED, imageType);
// rectify and undo distortion
distortRect1.apply(inputLeft, rectLeft);
distortRect2.apply(inputRight, rectRight);
rectifiedImages = true;
}
use of boofcv.struct.distort.DoNothing2Transform2_F64 in project BoofCV by lessthanoptimal.
the class TestMicroQrPose3DUtils method createAlg.
private MicroQrPose3DUtils createAlg() {
var alg = new MicroQrPose3DUtils();
alg.setLensDistortion(new Point2Transform2_F64() {
@Override
public void compute(double x, double y, Point2D_F64 out) {
// just change the point's scale to make it easy to see if it was applied
out.x = x * 0.1;
out.y = y * 0.1;
}
@Override
public Point2Transform2_F64 copyConcurrent() {
return null;
}
}, new DoNothing2Transform2_F64());
return alg;
}
Aggregations