Search in sources :

Example 21 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class TestRemoveRadialNtoN_F32 method checkManual.

public void checkManual(float t1, float t2) {
    /**/
    double[] radial = new /**/
    double[] { 0.12, -0.13 };
    // undisorted normalized image coordinate
    Point2D_F32 undistorted = new Point2D_F32(0.1f, -0.2f);
    // manually compute the distortion
    float x = undistorted.x, y = undistorted.y;
    float r2 = x * x + y * y;
    float mag = (float) radial[0] * r2 + (float) radial[1] * r2 * r2;
    // distorted normalized image coordinate
    float distX = undistorted.x * (1 + mag) + 2 * t1 * x * y + t2 * (r2 + 2 * x * x);
    float distY = undistorted.y * (1 + mag) + t1 * (r2 + 2 * y * y) + 2 * t2 * x * y;
    RemoveRadialNtoN_F32 alg = new RemoveRadialNtoN_F32().setDistortion(radial, t1, t2);
    Point2D_F32 found = new Point2D_F32();
    alg.compute(distX, distY, found);
    assertEquals(undistorted.x, found.x, GrlConstants.TEST_SQ_F32);
    assertEquals(undistorted.y, found.y, GrlConstants.TEST_SQ_F32);
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32)

Example 22 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class TestFlipVertical_F32 method basicTest.

@Test
public void basicTest() {
    FlipVertical_F32 alg = new FlipVertical_F32(100);
    Point2D_F32 found = new Point2D_F32();
    alg.compute(20, 30, found);
    assertEquals(20, found.x, 1e-8);
    assertEquals(100 - 30 - 1, found.y, 1e-8);
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Example 23 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class FeatureSpatialDiversity_F32 method computeCovarince.

private void computeCovarince() {
    meanX = 0;
    meanY = 0;
    for (int i = 0; i < norm.size; i++) {
        Point2D_F32 p = norm.get(i);
        meanX += p.x;
        meanY += p.y;
    }
    meanX /= norm.size;
    meanY /= norm.size;
    var.a11 = var.a12 = var.a22 = 0;
    for (int i = 0; i < norm.size; i++) {
        Point2D_F32 p = norm.get(i);
        float dx = p.x - meanX;
        float dy = p.y - meanY;
        var.a11 += dx * dx;
        var.a12 += dx * dy;
        var.a22 += dy * dy;
    }
    CommonOps_FDF2.divide(var, norm.size - 1);
// System.out.printf("  covar  %5.2f %5.2f %5.4f\n",var.a11,var.a22, var.a12);
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32)

Example 24 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class CreateSyntheticOverheadViewPL method process.

/**
 * Computes overhead view of input image.  All pixels in input image are assumed to be on the ground plane.
 *
 * @param input (Input) Camera image.
 * @param output (Output) Image containing overhead view.
 */
public void process(Planar<T> input, Planar<T> output) {
    int N = input.getNumBands();
    for (int i = 0; i < N; i++) {
        this.output[i] = FactoryGImageGray.wrap(output.getBand(i), this.output[i]);
        interp[i].setImage(input.getBand(i));
    }
    int indexMap = 0;
    for (int i = 0; i < output.height; i++) {
        int indexOut = output.startIndex + i * output.stride;
        for (int j = 0; j < output.width; j++, indexOut++, indexMap++) {
            Point2D_F32 p = mapPixels[indexMap];
            if (p != null) {
                for (int k = 0; k < N; k++) {
                    this.output[k].set(indexOut, interp[k].get(p.x, p.y));
                }
            }
        }
    }
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32)

Example 25 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class MultiCameraToEquirectangular method addCamera.

/**
 * Adds a camera and attempts to compute the mask from the provided distortion model.  if a pixel is rendered
 * outside the bounds in the input image then it is masked out.  If the forwards/backwards transform is too
 * different then it is masked out.
 *
 * @param cameraToCommon Rigid body transform from this camera to the common frame the equirectangular image
 *                       is in
 * @param factory Distortion model
 * @param width Input image width
 * @param height Input image height
 */
public void addCamera(Se3_F32 cameraToCommon, LensDistortionWideFOV factory, int width, int height) {
    Point2Transform3_F32 p2s = factory.undistortPtoS_F32();
    Point3Transform2_F32 s2p = factory.distortStoP_F32();
    EquiToCamera equiToCamera = new EquiToCamera(cameraToCommon.getR(), s2p);
    GrayF32 equiMask = new GrayF32(equiWidth, equHeight);
    PixelTransform2_F32 transformEquiToCam = new PixelTransformCached_F32(equiWidth, equHeight, new PointToPixelTransform_F32(equiToCamera));
    Point3D_F32 p3b = new Point3D_F32();
    Point2D_F32 p2 = new Point2D_F32();
    for (int row = 0; row < equHeight; row++) {
        for (int col = 0; col < equiWidth; col++) {
            equiToCamera.compute(col, row, p2);
            int camX = (int) (p2.x + 0.5f);
            int camY = (int) (p2.y + 0.5f);
            if (Double.isNaN(p2.x) || Double.isNaN(p2.y) || camX < 0 || camY < 0 || camX >= width || camY >= height)
                continue;
            p2s.compute(p2.x, p2.y, p3b);
            if (Double.isNaN(p3b.x) || Double.isNaN(p3b.y) || Double.isNaN(p3b.z))
                continue;
            double angle = UtilVector3D_F32.acute(equiToCamera.unitCam, p3b);
            if (angle < maskToleranceAngle) {
                equiMask.set(col, row, 1);
            }
        }
    }
    cameras.add(new Camera(equiMask, transformEquiToCam));
}
Also used : Point3D_F32(georegression.struct.point.Point3D_F32) GrayF32(boofcv.struct.image.GrayF32) PointToPixelTransform_F32(boofcv.alg.distort.PointToPixelTransform_F32) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform3_F32(boofcv.struct.distort.Point2Transform3_F32) Point3Transform2_F32(boofcv.struct.distort.Point3Transform2_F32) PixelTransform2_F32(boofcv.struct.distort.PixelTransform2_F32) PixelTransformCached_F32(boofcv.alg.distort.PixelTransformCached_F32)

Aggregations

Point2D_F32 (georegression.struct.point.Point2D_F32)98 Test (org.junit.Test)36 Point3D_F32 (georegression.struct.point.Point3D_F32)10 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)9 LineSegment2D_F32 (georegression.struct.line.LineSegment2D_F32)8 ArrayList (java.util.ArrayList)8 Point2D_F64 (georegression.struct.point.Point2D_F64)7 FMatrixRMaj (org.ejml.data.FMatrixRMaj)7 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)5 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)5 Point2Transform3_F32 (boofcv.struct.distort.Point2Transform3_F32)4 Point3Transform2_F32 (boofcv.struct.distort.Point3Transform2_F32)4 GrayF32 (boofcv.struct.image.GrayF32)4 ClosestPoint2D_F32 (georegression.metric.ClosestPoint2D_F32)4 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 GrayU8 (boofcv.struct.image.GrayU8)3 PixelTransformCached_F32 (boofcv.alg.distort.PixelTransformCached_F32)2 PinholePtoN_F32 (boofcv.alg.distort.pinhole.PinholePtoN_F32)2 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)2