Search in sources :

Example 6 with AztecCode

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

the class ExampleDetectAztecCode method main.

public static void main(String[] args) {
    BufferedImage input = UtilImageIO.loadImageNotNull(UtilIO.pathExample("fiducial/aztec/image01.jpg"));
    GrayU8 gray = ConvertBufferedImage.convertFrom(input, (GrayU8) null);
    var config = new ConfigAztecCode();
    // config.considerTransposed = false; // by default, it will consider incorrectly encoded markers. Faster if false
    AztecCodePreciseDetector<GrayU8> detector = FactoryFiducial.aztec(config, GrayU8.class);
    detector.process(gray);
    // Gets a list of all the qr codes it could successfully detect and decode
    List<AztecCode> detections = detector.getDetections();
    // Print the encoded messages
    for (AztecCode marker : detections) {
        System.out.println("message: '" + marker.message + "'");
    }
    // Visualize the found markers in the image
    Graphics2D g2 = input.createGraphics();
    // in large images the line can be too thin
    int strokeWidth = Math.max(4, input.getWidth() / 200);
    g2.setColor(Color.GREEN);
    g2.setStroke(new BasicStroke(strokeWidth));
    for (AztecCode marker : detections) {
        VisualizeShapes.drawPolygon(marker.bounds, true, 1, g2);
    }
    // List of objects it thinks might be a QR Code but failed for various reasons
    List<AztecCode> failures = detector.getFailures();
    g2.setColor(Color.RED);
    for (AztecCode marker : failures) {
        // If it failed to decode the mode then there's a decent change of it being a false negative
        if (marker.failure.ordinal() < AztecCode.Failure.MODE_ECC.ordinal())
            continue;
        VisualizeShapes.drawPolygon(marker.bounds, true, 1, g2);
    }
    ShowImages.showWindow(input, "Example Aztec Codes", true);
}
Also used : ConfigAztecCode(boofcv.factory.fiducial.ConfigAztecCode) AztecCode(boofcv.alg.fiducial.aztec.AztecCode) ConfigAztecCode(boofcv.factory.fiducial.ConfigAztecCode) GrayU8(boofcv.struct.image.GrayU8) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 7 with AztecCode

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

the class TestCreateAztecCodeDocument method gridAndCustomDocument.

@Test
void gridAndCustomDocument() throws IOException {
    createDocument("-t http://boofcv.org -t second -p 14cm:14cm --GridFill -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(4, 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 8 with AztecCode

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

the class TestCreateAztecCodeDocument method single.

@Test
void single() throws IOException {
    createDocument("-t http://boofcv.org -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();
    checkFound(found, "http://boofcv.org");
}
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 9 with AztecCode

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

the class ExampleRenderAztecCode method main.

public static void main(String[] args) {
    // Create a marker to render. Almost everything about how the marker is constructed can be manually specified
    // or you can let it automatically select everything
    AztecCode marker = new AztecEncoder().addAutomatic("Code 2D!").fixate();
    // NOTE: The final function you call must be fixate(), that's how it knows it's done
    // Render the marker as an image. It's also possible to render as a PDF or your own custom format
    GrayU8 rendered = AztecGenerator.renderImage(/* pixel per square */
    10, /* border squares */
    1, marker);
    // Convert it to a BufferedImage for display purposes
    BufferedImage output = ConvertBufferedImage.convertTo(rendered, null);
    // You can also save it to disk by uncommenting the line below
    // UtilImageIO.saveImage(output, "aztec.png");
    // Display the rendered marker
    ShowImages.showWindow(output, "Rendered Aztec Code", true);
}
Also used : AztecCode(boofcv.alg.fiducial.aztec.AztecCode) GrayU8(boofcv.struct.image.GrayU8) AztecEncoder(boofcv.alg.fiducial.aztec.AztecEncoder) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 10 with AztecCode

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

the class DetectAztecCodeMessagePanel method valueChanged.

@Override
public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting())
        return;
    if (e.getSource() == listDetected) {
        int selected = listDetected.getSelectedIndex();
        if (selected == -1)
            return;
        boolean failed = selected >= detected.size();
        if (failed) {
            selected -= detected.size();
            AztecCode marker = failures.get(selected);
            listener.selectedMarkerInList(selected, true);
            setMarkerMessageText(marker, true);
        } else {
            listener.selectedMarkerInList(selected, false);
            AztecCode marker = detected.get(selected);
            setMarkerMessageText(marker, false);
        }
        textArea.invalidate();
    }
}
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