Search in sources :

Example 71 with Point2D_F32

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

the class ImplPerspectiveOps_F32 method renderPixel.

public static Point2D_F32 renderPixel(FMatrixRMaj worldToCamera, Point3D_F32 X) {
    FMatrixRMaj P = worldToCamera;
    float x = P.data[0] * X.x + P.data[1] * X.y + P.data[2] * X.z + P.data[3];
    float y = P.data[4] * X.x + P.data[5] * X.y + P.data[6] * X.z + P.data[7];
    float z = P.data[8] * X.x + P.data[9] * X.y + P.data[10] * X.z + P.data[11];
    Point2D_F32 pixel = new Point2D_F32();
    pixel.x = x / z;
    pixel.y = y / z;
    return pixel;
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) Point2D_F32(georegression.struct.point.Point2D_F32)

Example 72 with Point2D_F32

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

the class ImplPerspectiveOps_F32 method convertPixelToNorm.

public static Point2D_F32 convertPixelToNorm(CameraModel param, Point2D_F32 pixel, Point2D_F32 norm) {
    if (norm == null)
        norm = new Point2D_F32();
    Point2Transform2_F32 pixelToNorm = LensDistortionOps.narrow(param).distort_F32(true, false);
    pixelToNorm.compute(pixel.x, pixel.y, norm);
    return norm;
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32)

Example 73 with Point2D_F32

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

the class ImplPerspectiveOps_F32 method convertNormToPixel.

public static Point2D_F32 convertNormToPixel(CameraModel param, float x, float y, Point2D_F32 pixel) {
    if (pixel == null)
        pixel = new Point2D_F32();
    Point2Transform2_F32 normToPixel = LensDistortionOps.narrow(param).distort_F32(false, true);
    normToPixel.compute(x, y, pixel);
    return pixel;
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32)

Example 74 with Point2D_F32

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

the class TestRectifyImageOps method transform_PixelToRect_and_RectToPixel_F32.

/**
 * Transforms and then performs the inverse transform to distorted rectified pixel
 */
@Test
public void transform_PixelToRect_and_RectToPixel_F32() {
    CameraPinholeRadial param = new CameraPinholeRadial().fsetK(300, 320, 0, 150, 130, width, height).fsetRadial(0.1, 1e-4);
    FMatrixRMaj rect = new FMatrixRMaj(3, 3, true, 1.1f, 0, 0, 0, 2, 0, 0.1f, 0, 3);
    Point2Transform2_F32 forward = RectifyImageOps.transformPixelToRect(param, rect);
    Point2Transform2_F32 inverse = RectifyImageOps.transformRectToPixel(param, rect);
    float x = 20, y = 30;
    Point2D_F32 out = new Point2D_F32();
    forward.compute(x, y, out);
    // sanity check
    assertTrue(Math.abs(x - out.x) > 1e-4);
    assertTrue(Math.abs(y - out.y) > 1e-4);
    inverse.compute(out.x, out.y, out);
    assertEquals(x, out.x, 1e-4);
    assertEquals(y, out.y, 1e-4);
}
Also used : FMatrixRMaj(org.ejml.data.FMatrixRMaj) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F32(georegression.struct.point.Point2D_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32) Test(org.junit.Test)

Example 75 with Point2D_F32

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

the class TestUniOmniStoP_F32 method worldIsImageCenter.

/**
 * A point in the world center should appear in the image center
 */
@Test
public void worldIsImageCenter() {
    CameraUniversalOmni model = createModel(0.5f);
    UniOmniStoP_F32 alg = new UniOmniStoP_F32();
    alg.setModel(model);
    Point2D_F32 found = new Point2D_F32(10, 10);
    // directly forward on unit sphere
    alg.compute(0, 0, 1, found);
    assertEquals(320, found.x, GrlConstants.TEST_F32);
    assertEquals(240, found.y, GrlConstants.TEST_F32);
}
Also used : CameraUniversalOmni(boofcv.struct.calib.CameraUniversalOmni) Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

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