Search in sources :

Example 1 with AztecCode

use of boofcv.alg.fiducial.aztec.AztecCode in project BoofCV by lessthanoptimal.

the class GenericAztecCodeDetectorChecks method multipleMarkers.

/**
 * See if it can detect multiple fiducials in the image at the same time
 */
@Test
void multipleMarkers() {
    AztecCodeDetector<GrayF32> detector = createDetector();
    CameraPinholeBrown 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.addSurface(markerToWorld0, simulatedTargetWidth, generateMarker());
    simulator.addSurface(markerToWorld1, simulatedTargetWidth, generateMarker());
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, Math.PI, 0, markerToWorld0.R);
    markerToWorld0.T.setTo(0.2, 0, 0.6);
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, Math.PI, 0, markerToWorld1.R);
    markerToWorld1.T.setTo(-0.2, 0, 0.6);
    simulator.render();
    detector.process(simulator.getOutput());
    if (display) {
        ShowImages.showWindow(simulator.getOutput(), ShowImages.Colorization.MAGNITUDE, "Foo", true);
        BoofMiscOps.sleep(10000);
    }
    List<AztecCode> detections = detector.getDetections();
    assertEquals(2, detections.size());
}
Also used : SimulatePlanarWorld(boofcv.simulation.SimulatePlanarWorld) GrayF32(boofcv.struct.image.GrayF32) CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) AztecCode(boofcv.alg.fiducial.aztec.AztecCode) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Example 2 with AztecCode

use of boofcv.alg.fiducial.aztec.AztecCode in project BoofCV by lessthanoptimal.

the class AztecCodePreciseDetector method process.

@Override
public void process(T gray) {
    // Reset and initialize
    allMarkers.reset();
    detected.clear();
    failed.clear();
    // Detect finder patterns
    inputToBinary.process(gray, binary);
    detectorPyramids.process(gray, binary);
    // Attempt to decode candidate markers
    List<AztecPyramid> pyramids = detectorPyramids.getFound().toList();
    if (verbose != null)
        verbose.println("Total pyramids found: " + pyramids.size());
    for (int locatorIdx = 0; locatorIdx < pyramids.size(); locatorIdx++) {
        AztecPyramid pyramid = pyramids.get(locatorIdx);
        if (verbose != null)
            verbose.println("Considering pyramid at: " + pyramid.get(0).center);
        AztecCode marker = allMarkers.grow();
        if (decoder.process(pyramid, gray, marker)) {
            detected.add(marker);
        } else {
            failed.add(marker);
        }
    }
}
Also used : AztecPyramid(boofcv.alg.fiducial.aztec.AztecPyramid) AztecCode(boofcv.alg.fiducial.aztec.AztecCode) VerbosePrint(org.ddogleg.struct.VerbosePrint)

Example 3 with AztecCode

use of boofcv.alg.fiducial.aztec.AztecCode in project BoofCV by lessthanoptimal.

the class BenchmarkAztecCodeDetector method setup.

/**
 * Generate a set of synthetic images with two markers in it to test against
 */
@Setup
public void setup() {
    var rand = new Random(BoofTesting.BASE_SEED);
    AztecCode marker1 = new AztecEncoder().addAutomatic("small").fixate();
    AztecCode marker2 = new AztecEncoder().addAutomatic("Much Larger Than the Oth9er!!#").fixate();
    GrayU8 image1 = AztecGenerator.renderImage(5, 0, marker1);
    GrayU8 image2 = AztecGenerator.renderImage(5, 0, marker2);
    var fullImage = new GrayU8(image1.width + image2.width + 50, image1.width + image2.width + 100);
    GImageMiscOps.fillUniform(fullImage, rand, 50, 150);
    GImageMiscOps.copy(0, 0, 10, 15, image1.width, image1.height, image1, fullImage);
    GImageMiscOps.copy(0, 0, 20 + image1.width, 50, image2.width, image2.height, image2, fullImage);
    images.add(fullImage);
    // manually checked that all the distorted images have markers inside the image
    for (int i = 0; i < 4; i++) {
        GrayU8 distorted = fullImage.createSameShape();
        new FDistort(fullImage, distorted).affine(1.0 + rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.01, rand.nextGaussian() * 0.01, 1.0 + rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.5, rand.nextGaussian() * 0.5).apply();
        images.add(distorted);
    }
}
Also used : Random(java.util.Random) FDistort(boofcv.abst.distort.FDistort) AztecCode(boofcv.alg.fiducial.aztec.AztecCode) GrayU8(boofcv.struct.image.GrayU8) AztecEncoder(boofcv.alg.fiducial.aztec.AztecEncoder)

Example 4 with AztecCode

use of boofcv.alg.fiducial.aztec.AztecCode in project BoofCV by lessthanoptimal.

the class TestCreateAztecCodeDocument method two.

@Test
void two() throws IOException {
    createDocument("-t http://boofcv.org -t second -p LETTER -w 5 -o target.pdf");
    BufferedImage image = loadPDF();
    GrayF32 gray = ConvertBufferedImage.convertFrom(image, (GrayF32) null);
    // ShowImages.showBlocking(gray,"Rendered", 10_000, true);
    AztecCodeDetector<GrayF32> detector = FactoryFiducial.aztec(null, GrayF32.class);
    detector.process(gray);
    List<AztecCode> found = detector.getDetections();
    assertEquals(2, found.size());
    checkFound(found, "http://boofcv.org", "second");
}
Also used : GrayF32(boofcv.struct.image.GrayF32) AztecCode(boofcv.alg.fiducial.aztec.AztecCode) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) Test(org.junit.jupiter.api.Test)

Example 5 with AztecCode

use of boofcv.alg.fiducial.aztec.AztecCode in project BoofCV by lessthanoptimal.

the class DetectAztecCodeMessagePanel method updateList.

public void updateList(List<AztecCode> detected, List<AztecCode> failures) {
    BoofSwingUtil.checkGuiThread();
    this.listDetected.removeListSelectionListener(this);
    DefaultListModel<String> model = (DefaultListModel) listDetected.getModel();
    model.clear();
    this.detected.clear();
    for (int i = 0; i < detected.size(); i++) {
        AztecCode marker = detected.get(i);
        String shortName = marker.structure.toString().substring(0, 4);
        model.addElement(String.format("%4s L=%02d %.10s", shortName, marker.dataLayers, marker.message));
        this.detected.add(marker.copy());
    }
    this.failures.clear();
    for (int i = 0; i < failures.size(); i++) {
        AztecCode marker = failures.get(i);
        String shortName = marker.structure.toString().substring(0, 4);
        model.addElement(String.format("%4s L=%02d %s", shortName, marker.dataLayers, marker.failure));
        this.failures.add(marker.copy());
    }
    listDetected.invalidate();
    listDetected.repaint();
    textArea.setText("");
    this.listDetected.addListSelectionListener(this);
}
Also used : AztecCode(boofcv.alg.fiducial.aztec.AztecCode)

Aggregations

AztecCode (boofcv.alg.fiducial.aztec.AztecCode)11 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)5 BufferedImage (java.awt.image.BufferedImage)5 GrayF32 (boofcv.struct.image.GrayF32)4 Test (org.junit.jupiter.api.Test)4 GrayU8 (boofcv.struct.image.GrayU8)3 AztecEncoder (boofcv.alg.fiducial.aztec.AztecEncoder)2 FDistort (boofcv.abst.distort.FDistort)1 AztecPyramid (boofcv.alg.fiducial.aztec.AztecPyramid)1 ConfigAztecCode (boofcv.factory.fiducial.ConfigAztecCode)1 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)1 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)1 Se3_F64 (georegression.struct.se.Se3_F64)1 Random (java.util.Random)1 VerbosePrint (org.ddogleg.struct.VerbosePrint)1