Search in sources :

Example 1 with DetectMultiFiducialCalibration

use of boofcv.abst.geo.calibration.DetectMultiFiducialCalibration in project BoofCV by lessthanoptimal.

the class GenericDetectMultiFiducialCalibrationChecks method basicPinhole.

@Test
void basicPinhole() {
    DetectMultiFiducialCalibration detector = createDetector();
    // CameraPinholeBrown model = CalibrationIO.load(getClass().getResource("pinhole_radial.yaml"));
    CameraPinholeBrown model = new CameraPinholeBrown().fsetK(600, 600, 0, 400, 400, 800, 800);
    SimulatePlanarWorld simulator = new SimulatePlanarWorld();
    simulator.setCamera(model);
    DogArray<List<PointIndex2D_F64>> markerPoints = new DogArray<>(ArrayList::new);
    for (int i = 0; i < Math.min(2, detector.getTotalUniqueMarkers()); i++) {
        GrayF32 pattern = renderPattern(i, markerPoints.grow());
        Se3_F64 markerToWorld = SpecialEuclideanOps_F64.eulerXyz((-0.5 + i) * 0.32, 0, .5, 0, Math.PI, 0, null);
        simulator.addSurface(markerToWorld, simulatedTargetWidth, pattern);
    }
    // marker systems since that requires encoding that should remove that ambiguity
    for (int cameraOriIdx = 0; cameraOriIdx < 10; cameraOriIdx++) {
        double roll = 2.0 * Math.PI * cameraOriIdx / 10;
        simulator.setWorldToCamera(SpecialEuclideanOps_F64.eulerXyz(0, 0, 0, 0, 0, roll, null));
        simulator.render();
        // Process the image and see if it detected everything
        detector.process(simulator.getOutput());
        // ShowImages.showWindow(simulator.getOutput(), "Rotated "+cameraOriIdx);
        // BoofMiscOps.sleep(2_000);
        // Number of markers which are not anonymous
        int totalIdentified = 0;
        for (int i = 0; i < detector.getDetectionCount(); i++) {
            if (detector.getMarkerID(i) >= 0)
                totalIdentified++;
        }
        if (visualizeFailures && 2 != totalIdentified) {
            UtilImageIO.saveImage(simulator.getOutput(), "failed.png");
            ShowImages.showWindow(simulator.getOutput(), "Simulated");
            BoofMiscOps.sleep(10_000);
        }
        assertEquals(2, totalIdentified);
        for (int i = 0; i < detector.getDetectionCount(); i++) {
            int markerID = detector.getMarkerID(i);
            // Ignore anonymous markers
            if (markerID < 0)
                continue;
            // See if it detected the expected number of calibration points on the marker
            assertEquals(markerPoints.get(markerID).size(), detector.getDetectedPoints(i).size());
        // TODO check the actual coordinates
        }
    }
}
Also used : DetectMultiFiducialCalibration(boofcv.abst.geo.calibration.DetectMultiFiducialCalibration) SimulatePlanarWorld(boofcv.simulation.SimulatePlanarWorld) GrayF32(boofcv.struct.image.GrayF32) CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DogArray(org.ddogleg.struct.DogArray) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Aggregations

DetectMultiFiducialCalibration (boofcv.abst.geo.calibration.DetectMultiFiducialCalibration)1 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)1 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)1 GrayF32 (boofcv.struct.image.GrayF32)1 Se3_F64 (georegression.struct.se.Se3_F64)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DogArray (org.ddogleg.struct.DogArray)1 Test (org.junit.jupiter.api.Test)1