Search in sources :

Example 71 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class GenericFiducialDetectorChecks method checkImageLocation.

@Test
public void checkImageLocation() {
    for (ImageType type : types) {
        ImageBase image = loadImage(type);
        FiducialDetector detector = createDetector(type);
        // It's not specified if the center should be undistorted or distorted. Just make it easier by
        // using undistorted
        LensDistortionNarrowFOV distortion = loadDistortion(false);
        detector.setLensDistortion(distortion, image.width, image.height);
        detector.detect(image);
        assertTrue(detector.totalFound() >= 1);
        assertTrue(detector.is3D());
        for (int i = 0; i < detector.totalFound(); i++) {
            Se3_F64 fidToCam = new Se3_F64();
            Point2D_F64 found = new Point2D_F64();
            detector.getFiducialToCamera(i, fidToCam);
            detector.getCenter(i, found);
            Point2D_F64 rendered = new Point2D_F64();
            WorldToCameraToPixel worldToPixel = PerspectiveOps.createWorldToPixel(distortion, fidToCam);
            worldToPixel.transform(new Point3D_F64(0, 0, 0), rendered);
            // see if the reprojected is near the pixel location
            assertTrue(rendered.distance(found) <= pixelAndProjectedTol);
        }
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) LensDistortionNarrowFOV(boofcv.alg.distort.LensDistortionNarrowFOV) WorldToCameraToPixel(boofcv.alg.geo.WorldToCameraToPixel) ImageBase(boofcv.struct.image.ImageBase) ImageType(boofcv.struct.image.ImageType) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 72 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class GenericFiducialDetectorChecks method checkMultipleRuns.

@Test
public void checkMultipleRuns() {
    for (ImageType type : types) {
        ImageBase image = loadImage(type);
        FiducialDetector detector = createDetector(type);
        detector.setLensDistortion(loadDistortion(true), image.width, image.height);
        detector.detect(image);
        assertTrue(detector.totalFound() >= 1);
        Results results = extractResults(detector);
        // run it again
        detector.detect(image);
        // see if it produced exactly the same results
        assertEquals(results.id.length, detector.totalFound());
        for (int i = 0; i < detector.totalFound(); i++) {
            assertEquals(results.id[i], detector.getId(i));
            Se3_F64 pose = new Se3_F64();
            detector.getFiducialToCamera(i, pose);
            assertEquals(0, pose.getT().distance(results.pose.get(i).T), 1e-8);
            assertTrue(MatrixFeatures_DDRM.isIdentical(pose.getR(), results.pose.get(i).R, 1e-8));
        }
    }
}
Also used : ImageBase(boofcv.struct.image.ImageBase) ImageType(boofcv.struct.image.ImageType) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 73 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class GenericFiducialDetectorChecks method checkHandleNewIntrinsic.

/**
 * Tests several items:
 *
 * 1) Does it properly handle setIntrinsic() being called multiple times
 * 2) Can it handle no distortion
 */
@Test
public void checkHandleNewIntrinsic() {
    for (ImageType type : types) {
        ImageBase image = loadImage(type);
        FiducialDetector detector = createDetector(type);
        detector.setLensDistortion(loadDistortion(true), image.width, image.height);
        detector.detect(image);
        assertTrue(detector.totalFound() >= 1);
        checkBounds(detector);
        Results results = extractResults(detector);
        // run it again with a changed intrinsic that's incorrect
        detector.setLensDistortion(loadDistortion(false), image.width, image.height);
        detector.detect(image);
        checkBounds(detector);
        // results should have changed
        if (results.id.length == detector.totalFound()) {
            assertEquals(results.id.length, detector.totalFound());
            for (int i = 0; i < detector.totalFound(); i++) {
                assertEquals(results.id[i], detector.getId(i));
                Se3_F64 pose = new Se3_F64();
                Point2D_F64 pixel = new Point2D_F64();
                detector.getFiducialToCamera(i, pose);
                detector.getCenter(i, pixel);
                assertTrue(pose.getT().distance(results.pose.get(i).T) > 1e-4);
                assertFalse(MatrixFeatures_DDRM.isIdentical(pose.getR(), results.pose.get(i).R, 1e-4));
                // pixel location is based on the observed location, thus changing the intrinsics should not
                // affect it
                assertTrue(results.pixel.get(i).distance(pixel) <= 2.0);
            }
        } else {
        // clearly changed
        }
        // then reproduce original
        detector.setLensDistortion(loadDistortion(true), image.width, image.height);
        detector.detect(image);
        // see if it produced exactly the same results
        assertEquals(results.id.length, detector.totalFound());
        for (int i = 0; i < detector.totalFound(); i++) {
            assertEquals(results.id[i], detector.getId(i));
            Se3_F64 pose = new Se3_F64();
            detector.getFiducialToCamera(i, pose);
            assertEquals(0, pose.getT().distance(results.pose.get(i).T), 1e-8);
            assertTrue(MatrixFeatures_DDRM.isIdentical(pose.getR(), results.pose.get(i).R, 1e-8));
        }
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) ImageBase(boofcv.struct.image.ImageBase) ImageType(boofcv.struct.image.ImageType) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 74 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class GenericFiducialDetectorChecks method checkSubImage.

@Test
public void checkSubImage() {
    for (ImageType type : types) {
        ImageBase image = loadImage(type);
        FiducialDetector detector = createDetector(type);
        detector.setLensDistortion(loadDistortion(true), image.width, image.height);
        detector.detect(image);
        assertTrue(detector.totalFound() >= 1);
        long[] foundID = new long[detector.totalFound()];
        List<Se3_F64> foundPose = new ArrayList<>();
        for (int i = 0; i < detector.totalFound(); i++) {
            foundID[i] = detector.getId(i);
            Se3_F64 pose = new Se3_F64();
            detector.getFiducialToCamera(i, pose);
            foundPose.add(pose);
        }
        // run it again with a sub-image
        detector.detect(BoofTesting.createSubImageOf(image));
        // see if it produced exactly the same results
        assertEquals(foundID.length, detector.totalFound());
        for (int i = 0; i < detector.totalFound(); i++) {
            assertEquals(foundID[i], detector.getId(i));
            Se3_F64 pose = new Se3_F64();
            detector.getFiducialToCamera(i, pose);
            assertEquals(0, pose.getT().distance(foundPose.get(i).T), 1e-8);
            assertTrue(MatrixFeatures_DDRM.isIdentical(pose.getR(), foundPose.get(i).R, 1e-8));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ImageBase(boofcv.struct.image.ImageBase) ImageType(boofcv.struct.image.ImageType) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 75 with Se3_F64

use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.

the class GenericQrCodeDetectorChecks method rotation.

/**
 * See if a clear well defined qr code can be detected while rating
 */
@Test
public void rotation() {
    QrCodeDetector<GrayF32> detector = createDetector();
    CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("calib/pinhole_radial.yaml"));
    SimulatePlanarWorld simulator = new SimulatePlanarWorld();
    simulator.setCamera(model);
    simulator.resetScene();
    Se3_F64 markerToWorld = new Se3_F64();
    simulator.addTarget(markerToWorld, simulatedTargetWidth, generateMarker());
    markerToWorld.T.set(0, 0, 0.5);
    for (int i = 0; i < 30; i++) {
        double roll = 2 * Math.PI * i / 30.0;
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, 0, roll, markerToWorld.R);
        renderAndCheck(detector, simulator);
    }
}
Also used : SimulatePlanarWorld(boofcv.simulation.SimulatePlanarWorld) GrayF32(boofcv.struct.image.GrayF32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Aggregations

Se3_F64 (georegression.struct.se.Se3_F64)214 Test (org.junit.Test)83 Point3D_F64 (georegression.struct.point.Point3D_F64)74 Point2D_F64 (georegression.struct.point.Point2D_F64)68 DMatrixRMaj (org.ejml.data.DMatrixRMaj)52 Point2D3D (boofcv.struct.geo.Point2D3D)31 Vector3D_F64 (georegression.struct.point.Vector3D_F64)30 ArrayList (java.util.ArrayList)27 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)26 GrayF32 (boofcv.struct.image.GrayF32)18 AssociatedPair (boofcv.struct.geo.AssociatedPair)17 StereoParameters (boofcv.struct.calib.StereoParameters)12 GrayU8 (boofcv.struct.image.GrayU8)10 BufferedImage (java.awt.image.BufferedImage)10 PointTrack (boofcv.abst.feature.tracker.PointTrack)9 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)9 Stereo2D3D (boofcv.struct.sfm.Stereo2D3D)9 ModelManagerSe3_F64 (georegression.fitting.se.ModelManagerSe3_F64)9 RectifyCalibrated (boofcv.alg.geo.rectify.RectifyCalibrated)8 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)7