Search in sources :

Example 1 with PixelTransform

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

the class TestDepthSparse3D method basicTest.

@Test
void basicTest() {
    GrayU16 depth = new GrayU16(w, h);
    depth.set(5, 6, 1000);
    CameraPinholeBrown param = new CameraPinholeBrown(1, 1, 0, 5, 10, w, h).fsetRadial(0, 0);
    PixelTransform<Point2D_F32> v2d = new PixelTransform<Point2D_F32>() {

        @Override
        public void compute(int x, int y, Point2D_F32 output) {
            output.x = x + 1;
            output.y = y + 2;
        }

        @Override
        public PixelTransform<Point2D_F32> copyConcurrent() {
            return null;
        }
    };
    DepthSparse3D<GrayU16> alg = new DepthSparse3D.I<>(2.1);
    alg.configure(LensDistortionFactory.narrow(param), v2d);
    alg.setDepthImage(depth);
    assertTrue(alg.process(4, 4));
    Point3D_F64 found = alg.getWorldPt();
    Point2D_F64 norm = new Point2D_F64();
    PerspectiveOps.convertPixelToNorm(param, new Point2D_F64(4, 4), norm);
    double z = 1000 * 2.1;
    assertEquals(z, found.z, 1e-8);
    assertEquals(norm.x * z, found.x, 1e-8);
    assertEquals(norm.y * z, found.y, 1e-8);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) GrayU16(boofcv.struct.image.GrayU16) Point2D_F64(georegression.struct.point.Point2D_F64) Point2D_F32(georegression.struct.point.Point2D_F32) PixelTransform(boofcv.struct.distort.PixelTransform) Test(org.junit.jupiter.api.Test)

Example 2 with PixelTransform

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

the class FactoryStitchingTransform method createAffine_F64.

public static StitchingTransform<Affine2D_F64> createAffine_F64() {
    return new StitchingTransform<>() {

        final Affine2D_F32 input_F32 = new Affine2D_F32();

        @Override
        public PixelTransform<Point2D_F32> convertPixel(Affine2D_F64 input, @Nullable PixelTransform<Point2D_F32> output) {
            ConvertFloatType.convert(input, input_F32);
            if (output != null) {
                ((PixelTransformAffine_F32) output).setTo(input_F32);
            } else {
                PixelTransformAffine_F32 a = new PixelTransformAffine_F32();
                a.setTo(input_F32);
                output = a;
            }
            return output;
        }

        @Override
        public Homography2D_F64 convertH(Affine2D_F64 input, @Nullable Homography2D_F64 output) {
            if (output == null)
                output = new Homography2D_F64();
            output.setTo(input.a11, input.a12, input.tx, input.a21, input.a22, input.ty, 0, 0, 1);
            return output;
        }
    };
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) Affine2D_F32(georegression.struct.affine.Affine2D_F32) Point2D_F32(georegression.struct.point.Point2D_F32) PixelTransformAffine_F32(boofcv.alg.distort.PixelTransformAffine_F32) Homography2D_F64(georegression.struct.homography.Homography2D_F64) Nullable(org.jetbrains.annotations.Nullable) PixelTransform(boofcv.struct.distort.PixelTransform)

Aggregations

PixelTransform (boofcv.struct.distort.PixelTransform)2 Point2D_F32 (georegression.struct.point.Point2D_F32)2 PixelTransformAffine_F32 (boofcv.alg.distort.PixelTransformAffine_F32)1 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)1 GrayU16 (boofcv.struct.image.GrayU16)1 Affine2D_F32 (georegression.struct.affine.Affine2D_F32)1 Affine2D_F64 (georegression.struct.affine.Affine2D_F64)1 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)1 Point2D_F64 (georegression.struct.point.Point2D_F64)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1 Nullable (org.jetbrains.annotations.Nullable)1 Test (org.junit.jupiter.api.Test)1