Search in sources :

Example 1 with Point2Transform2_F64

use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.

the class ExampleStereoTwoViewsOneCamera method convertToNormalizedCoordinates.

/**
 * Convert a set of associated point features from pixel coordinates into normalized image coordinates.
 */
public static List<AssociatedPair> convertToNormalizedCoordinates(List<AssociatedPair> matchedFeatures, CameraPinholeRadial intrinsic) {
    Point2Transform2_F64 p_to_n = LensDistortionOps.narrow(intrinsic).undistort_F64(true, false);
    List<AssociatedPair> calibratedFeatures = new ArrayList<>();
    for (AssociatedPair p : matchedFeatures) {
        AssociatedPair c = new AssociatedPair();
        p_to_n.compute(p.p1.x, p.p1.y, c.p1);
        p_to_n.compute(p.p2.x, p.p2.y, c.p2);
        calibratedFeatures.add(c);
    }
    return calibratedFeatures;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) ArrayList(java.util.ArrayList)

Example 2 with Point2Transform2_F64

use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.

the class ImplRectifyImageOps_F64 method transformPixelToRect.

public static Point2Transform2_F64 transformPixelToRect(CameraPinholeRadial param, DMatrixRMaj rectify) {
    Point2Transform2_F64 remove_p_to_p = narrow(param).undistort_F64(true, true);
    PointTransformHomography_F64 rectifyDistort = new PointTransformHomography_F64(rectify);
    return new SequencePoint2Transform2_F64(remove_p_to_p, rectifyDistort);
}
Also used : PointTransformHomography_F64(boofcv.alg.distort.PointTransformHomography_F64) SequencePoint2Transform2_F64(boofcv.struct.distort.SequencePoint2Transform2_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) SequencePoint2Transform2_F64(boofcv.struct.distort.SequencePoint2Transform2_F64)

Example 3 with Point2Transform2_F64

use of boofcv.struct.distort.Point2Transform2_F64 in project narchy by automenta.

the class ExampleStereoTwoViewsOneCamera method drawInliers.

/**
 * Draw inliers for debugging purposes.  Need to convert from normalized to pixel coordinates.
 */
public void drawInliers(CameraPinholeRadial intrinsic, List<AssociatedPair> normalized) {
    Point2Transform2_F64 n_to_p = LensDistortionOps.narrow(intrinsic).distort_F64(false, true);
    List<AssociatedPair> pixels = new ArrayList<>(normalized.size());
    for (AssociatedPair n : normalized) {
        AssociatedPair p = new AssociatedPair();
        n_to_p.compute(n.p1.x, n.p1.y, p.p1);
        n_to_p.compute(n.p2.x, n.p2.y, p.p2);
        pixels.add(p);
    }
    // display the results
    assocPanel.setAssociation(pixels);
    assocPanel.setImages(ConvertBufferedImage.extractBuffered(distortedPrev), ConvertBufferedImage.extractBuffered(distortedNext));
    assocPanel.repaint();
    assocPanel.setSize(500, 100);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) ArrayList(java.util.ArrayList)

Example 4 with Point2Transform2_F64

use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.

the class CameraToEquirectangular_F64 method setCameraModel.

public void setCameraModel(CameraPinholeBrown camera) {
    Point2Transform2_F64 pixelToNormalized = new LensDistortionBrown(camera).undistort_F64(true, false);
    setCameraModel(camera.width, camera.height, pixelToNormalized);
}
Also used : LensDistortionBrown(boofcv.alg.distort.brown.LensDistortionBrown) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64)

Example 5 with Point2Transform2_F64

use of boofcv.struct.distort.Point2Transform2_F64 in project BoofCV by lessthanoptimal.

the class QrCodeDetectorPnP method setLensDistortion.

@Override
public void setLensDistortion(@Nullable LensDistortionNarrowFOV distortion, int width, int height) {
    super.setLensDistortion(distortion, width, height);
    if (distortion == null) {
        poseUtils.setLensDistortion(null, null);
        // Yes this shouldn't be hard coded to that type. It feels dirty adding lens distortion to the
        // generic QR Code detector... deal with this later if there is more than one detector
        ((QrCodePreciseDetector) detector).setLensDistortion(width, height, null);
    } else {
        Point2D_F64 test = new Point2D_F64();
        Point2Transform2_F64 undistToDist = distortion.distort_F64(true, true);
        undistToDist.compute(0, 0, test);
        poseUtils.setLensDistortion(distortion.undistort_F64(true, false), undistToDist);
        // If there's no actual distortion don't undistort the image while processing. Faster this way
        if (test.norm() <= UtilEjml.TEST_F32) {
            ((QrCodePreciseDetector) detector).setLensDistortion(width, height, null);
        } else {
            ((QrCodePreciseDetector) detector).setLensDistortion(width, height, distortion);
        }
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64)

Aggregations

Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)66 Point2D_F64 (georegression.struct.point.Point2D_F64)32 Test (org.junit.jupiter.api.Test)16 Point3D_F64 (georegression.struct.point.Point3D_F64)15 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)13 SequencePoint2Transform2_F64 (boofcv.struct.distort.SequencePoint2Transform2_F64)11 Se3_F64 (georegression.struct.se.Se3_F64)11 CameraPinhole (boofcv.struct.calib.CameraPinhole)9 LensDistortionBrown (boofcv.alg.distort.brown.LensDistortionBrown)8 PointToPixelTransform_F64 (boofcv.struct.distort.PointToPixelTransform_F64)8 ArrayList (java.util.ArrayList)8 PointTransformHomography_F64 (boofcv.alg.distort.PointTransformHomography_F64)7 AssociatedPair (boofcv.struct.geo.AssociatedPair)6 GrayF32 (boofcv.struct.image.GrayF32)6 LensDistortionPinhole (boofcv.alg.distort.pinhole.LensDistortionPinhole)5 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)5 GrayU8 (boofcv.struct.image.GrayU8)5 RectangleLength2D_F64 (georegression.struct.shapes.RectangleLength2D_F64)5 DMatrixRMaj (org.ejml.data.DMatrixRMaj)4 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)3