Search in sources :

Example 6 with DoNothing2Transform2_F64

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);
}
Also used : DisparityToColorPointCloud(boofcv.alg.cloud.DisparityToColorPointCloud) DoNothing2Transform2_F64(boofcv.struct.distort.DoNothing2Transform2_F64) PointCloudViewer(boofcv.visualize.PointCloudViewer) PointCloudWriter(boofcv.alg.cloud.PointCloudWriter) CameraPinhole(boofcv.struct.calib.CameraPinhole) Se3_F64(georegression.struct.se.Se3_F64)

Example 7 with DoNothing2Transform2_F64

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;
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) DMatrixRMaj(org.ejml.data.DMatrixRMaj) DoNothing2Transform2_F64(boofcv.struct.distort.DoNothing2Transform2_F64) Se3_F64(georegression.struct.se.Se3_F64)

Example 8 with DoNothing2Transform2_F64

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;
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) DoNothing2Transform2_F64(boofcv.struct.distort.DoNothing2Transform2_F64)

Aggregations

DoNothing2Transform2_F64 (boofcv.struct.distort.DoNothing2Transform2_F64)8 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)3 Se3_F64 (georegression.struct.se.Se3_F64)3 DMatrixRMaj (org.ejml.data.DMatrixRMaj)3 Point2D_F64 (georegression.struct.point.Point2D_F64)2 DisparityToColorPointCloud (boofcv.alg.cloud.DisparityToColorPointCloud)1 PointCloudWriter (boofcv.alg.cloud.PointCloudWriter)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 Point3dRgbI_F64 (boofcv.struct.Point3dRgbI_F64)1 CameraPinhole (boofcv.struct.calib.CameraPinhole)1 GrayF32 (boofcv.struct.image.GrayF32)1 PointCloudViewer (boofcv.visualize.PointCloudViewer)1 BufferedImage (java.awt.image.BufferedImage)1 DogArray (org.ddogleg.struct.DogArray)1 FMatrixRMaj (org.ejml.data.FMatrixRMaj)1 Test (org.junit.jupiter.api.Test)1