Search in sources :

Example 26 with Point2Transform2_F64

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

the class VisOdomPixelDepthPnP_to_DepthVisualOdometry method setCalibration.

@Override
public void setCalibration(CameraPinholeRadial paramVisual, Point2Transform2_F32 visToDepth) {
    PointToPixelTransform_F32 visToDepth_pixel = new PointToPixelTransform_F32(visToDepth);
    sparse3D.configure(LensDistortionOps.narrow(paramVisual), visToDepth_pixel);
    Point2Transform2_F64 leftPixelToNorm = narrow(paramVisual).undistort_F64(true, false);
    Point2Transform2_F64 leftNormToPixel = narrow(paramVisual).distort_F64(false, true);
    alg.setPixelToNorm(leftPixelToNorm);
    alg.setNormToPixel(leftNormToPixel);
    distance.setIntrinsic(paramVisual.fx, paramVisual.fy, paramVisual.skew);
}
Also used : PointToPixelTransform_F32(boofcv.alg.distort.PointToPixelTransform_F32) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64)

Example 27 with Point2Transform2_F64

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

the class CreateSyntheticOverheadView method configure.

/**
 * Specifies camera configurations.
 * @param intrinsic Intrinsic camera parameters
 * @param planeToCamera Transform from the plane to the camera.  This is the extrinsic parameters.
 * @param centerX X-coordinate of camera center in the overhead image in world units.
 * @param centerY Y-coordinate of camera center in the overhead image in world units.
 * @param cellSize Size of each cell in the overhead image in world units.
 * @param overheadWidth Number of columns in overhead image
 * @param overheadHeight Number of rows in overhead image
 */
public void configure(CameraPinholeRadial intrinsic, Se3_F64 planeToCamera, double centerX, double centerY, double cellSize, int overheadWidth, int overheadHeight) {
    this.overheadWidth = overheadWidth;
    this.overheadHeight = overheadHeight;
    Point2Transform2_F64 normToPixel = LensDistortionOps.narrow(intrinsic).distort_F64(false, true);
    // Declare storage for precomputed pixel locations
    int overheadPixels = overheadHeight * overheadWidth;
    if (mapPixels == null || mapPixels.length < overheadPixels) {
        mapPixels = new Point2D_F32[overheadPixels];
    }
    points.reset();
    // -------- storage for intermediate results
    Point2D_F64 pixel = new Point2D_F64();
    // coordinate on the plane
    Point3D_F64 pt_plane = new Point3D_F64();
    // coordinate in camera reference frame
    Point3D_F64 pt_cam = new Point3D_F64();
    int indexOut = 0;
    for (int i = 0; i < overheadHeight; i++) {
        pt_plane.x = -(i * cellSize - centerY);
        for (int j = 0; j < overheadWidth; j++, indexOut++) {
            pt_plane.z = j * cellSize - centerX;
            // plane to camera reference frame
            SePointOps_F64.transform(planeToCamera, pt_plane, pt_cam);
            // can't see behind the camera
            if (pt_cam.z > 0) {
                // compute normalized then convert to pixels
                normToPixel.compute(pt_cam.x / pt_cam.z, pt_cam.y / pt_cam.z, pixel);
                float x = (float) pixel.x;
                float y = (float) pixel.y;
                // make sure it's in the image
                if (BoofMiscOps.checkInside(intrinsic.width, intrinsic.height, x, y)) {
                    Point2D_F32 p = points.grow();
                    p.set(x, y);
                    mapPixels[indexOut] = p;
                } else {
                    mapPixels[indexOut] = null;
                }
            }
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) Point2D_F32(georegression.struct.point.Point2D_F32)

Example 28 with Point2Transform2_F64

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

the class ExampleStereoTwoViewsOneCamera method convertToNormalizedCoordinates.

/**
 * Convert a set of associated point features from pixel coordinates into normalized image coordinates.
 */
public void convertToNormalizedCoordinates(List<AssociatedPair> matchedFeatures, CameraPinholeRadial intrinsic) {
    Point2Transform2_F64 p_to_n = LensDistortionOps.narrow(intrinsic).undistort_F64(true, false);
    matchedCalibrated.clear();
    for (int i = 0, matchedFeaturesSize = matchedFeatures.size(); i < matchedFeaturesSize; i++) {
        AssociatedPair p = matchedFeatures.get(i);
        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);
        matchedCalibrated.add(c);
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint)

Aggregations

Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)28 Point2D_F64 (georegression.struct.point.Point2D_F64)15 Point3D_F64 (georegression.struct.point.Point3D_F64)7 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)6 SequencePoint2Transform2_F64 (boofcv.struct.distort.SequencePoint2Transform2_F64)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 PointTransformHomography_F64 (boofcv.alg.distort.PointTransformHomography_F64)4 AssociatedPair (boofcv.struct.geo.AssociatedPair)4 Se3_F64 (georegression.struct.se.Se3_F64)4 DMatrixRMaj (org.ejml.data.DMatrixRMaj)4 PointToPixelTransform_F64 (boofcv.alg.distort.PointToPixelTransform_F64)3 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)3 RectangleLength2D_F64 (georegression.struct.shapes.RectangleLength2D_F64)3 Point2D3D (boofcv.struct.geo.Point2D3D)2 GrayU8 (boofcv.struct.image.GrayU8)2 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)1 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)1 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)1 PinholePtoN_F64 (boofcv.alg.distort.pinhole.PinholePtoN_F64)1