Example Render Aztec Code
From BoofCV
Jump to navigationJump to search
This example shows how a Aztec Codes can be rendered into an image. Its easy to adapt the approach here for just about any file format, e.g. PDF.
Example Code:
Concepts:
- Fiducials
- Micro QR Codes
Relevant Examples/Tutorials:
Example Code
/**
* An easy-to-use API is provided for creating your own Aztec Code marker. You can render it as an image or PDF
* document.
*
* @author Peter Abeles
* @see MicroQrCodeGenerator
*/
public class ExampleRenderAztecCode {
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);
}
}