Search in sources :

Example 1 with SimulatePlanarWorld

use of boofcv.simulation.SimulatePlanarWorld 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)

Example 2 with SimulatePlanarWorld

use of boofcv.simulation.SimulatePlanarWorld in project BoofCV by lessthanoptimal.

the class GenericQrCodeDetectorChecks method skewed.

/**
 * The marker is at a skewed angle and rotating
 */
@Test
public void skewed() {
    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;
        double pitch = Math.PI * 0.3;
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, pitch, 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)

Example 3 with SimulatePlanarWorld

use of boofcv.simulation.SimulatePlanarWorld in project BoofCV by lessthanoptimal.

the class GenericPlanarCalibrationDetectorChecks method pinhole_radial_fullview.

/**
 * Simulated scene using a pinhole camera model with radial distortion. Entire target is visible
 */
@Test
public void pinhole_radial_fullview() {
    CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("pinhole_radial.yaml"));
    SimulatePlanarWorld simulator = new SimulatePlanarWorld();
    simulator.setCamera(model);
    List<Point2D_F64> locations2D = new ArrayList<>();
    GrayF32 pattern = new GrayF32(1, 1);
    for (int i = 0; i < targetConfigs.size(); i++) {
        // System.out.println("*---------- Configuration "+i);
        failedToDetect = 0;
        DetectorFiducialCalibration detector = createDetector(targetConfigs.get(i));
        renderTarget(targetConfigs.get(i), simulatedTargetWidth, pattern, locations2D);
        simulator.resetScene();
        Se3_F64 markerToWorld = new Se3_F64();
        simulator.addTarget(markerToWorld, simulatedTargetWidth, pattern);
        // up close exploding - center
        markerToWorld.T.set(0, 0, 0.5);
        checkRenderedResults(detector, simulator, locations2D);
        // farther away centered
        markerToWorld.T.set(0, 0, 1);
        checkRenderedResults(detector, simulator, locations2D);
        markerToWorld.T.set(-0.33, 0, 1);
        checkRenderedResults(detector, simulator, locations2D);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -1, 0, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -1, 0.8, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
        markerToWorld.T.set(-0.33, 0.33, 1);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -1, 0.8, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
        markerToWorld.T.set(0, -0.20, 1);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.8, -1, 0.8, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.8, -1, 1.8, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
        markerToWorld.T.set(0, -0.15, 1);
        ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.2, -1, 2.4, markerToWorld.getR());
        checkRenderedResults(detector, simulator, locations2D);
    }
    assertEquals(0, failedToDetect);
}
Also used : SimulatePlanarWorld(boofcv.simulation.SimulatePlanarWorld) DetectorFiducialCalibration(boofcv.abst.geo.calibration.DetectorFiducialCalibration) GrayF32(boofcv.struct.image.GrayF32) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 4 with SimulatePlanarWorld

use of boofcv.simulation.SimulatePlanarWorld in project BoofCV by lessthanoptimal.

the class GenericQrCodeDetectorChecks method multipleMarkers.

/**
 * See if it can detect multiple markers in the image at the same time
 */
@Test
public void multipleMarkers() {
    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 markerToWorld0 = new Se3_F64();
    Se3_F64 markerToWorld1 = new Se3_F64();
    simulator.addTarget(markerToWorld0, simulatedTargetWidth, generateMarker());
    simulator.addTarget(markerToWorld1, simulatedTargetWidth, generateMarker());
    markerToWorld0.T.set(0.2, 0, 0.6);
    markerToWorld1.T.set(-0.2, 0, 0.6);
    simulator.render();
    detector.process(simulator.getOutput());
    if (display) {
        ShowImages.showWindow(simulator.getOutput(), "Foo", true);
        BoofMiscOps.sleep(10000);
    }
    List<QrCode> detections = detector.getDetections();
    assertEquals(2, detections.size());
}
Also used : QrCode(boofcv.alg.fiducial.qrcode.QrCode) 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)

Example 5 with SimulatePlanarWorld

use of boofcv.simulation.SimulatePlanarWorld in project BoofCV by lessthanoptimal.

the class GenericQrCodeDetectorChecks method scale.

/**
 * The marker zooming in and out of the frame
 */
@Test
public void scale() {
    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.3);
    for (int i = 0; i < 30; i++) {
        renderAndCheck(detector, simulator);
        markerToWorld.T.z += 0.03;
    }
}
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

SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)7 GrayF32 (boofcv.struct.image.GrayF32)7 Se3_F64 (georegression.struct.se.Se3_F64)7 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)3 DetectorFiducialCalibration (boofcv.abst.geo.calibration.DetectorFiducialCalibration)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 QrCode (boofcv.alg.fiducial.qrcode.QrCode)1 CameraUniversalOmni (boofcv.struct.calib.CameraUniversalOmni)1