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);
}
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");
}
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");
}
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);
}
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();
}
}
Aggregations