Search in sources :

Example 96 with Point2D_F32

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

the class TestSequencePointTransform_F32 method simpleTest.

@Test
public void simpleTest() {
    Point2Transform2_F32 a = new Point2Transform2_F32() {

        @Override
        public void compute(float x, float y, Point2D_F32 out) {
            out.x = x + 1;
            out.y = y + 2;
        }
    };
    SequencePoint2Transform2_F32 alg = new SequencePoint2Transform2_F32(a, a);
    Point2D_F32 p = new Point2D_F32();
    alg.compute(3, 4, p);
    assertEquals(5, p.x, 1e-8);
    assertEquals(8, p.y, 1e-8);
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Example 97 with Point2D_F32

use of georegression.struct.point.Point2D_F32 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 98 with Point2D_F32

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

the class CreateSyntheticOverheadViewS 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(T input, T output) {
    this.output = FactoryGImageGray.wrap(output, this.output);
    interp.setImage(input);
    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) {
                this.output.set(indexOut, interp.get(p.x, p.y));
            }
        }
    }
}
Also used : Point2D_F32(georegression.struct.point.Point2D_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