https://boofcv.org/index.php?title=Example_Render_Aztec_Code&feed=atom&action=historyExample Render Aztec Code - Revision history2024-03-28T20:58:28ZRevision history for this page on the wikiMediaWiki 1.36.2https://boofcv.org/index.php?title=Example_Render_Aztec_Code&diff=3214&oldid=prevPeter: Created page with "<center> <gallery widths=400px heights=400px> File:Example_render_aztec_code.png | Rendered Aztec Code from this example </gallery> </center> This example shows how a [https:..."2022-09-03T00:31:48Z<p>Created page with "<center> <gallery widths=400px heights=400px> File:Example_render_aztec_code.png | Rendered Aztec Code from this example </gallery> </center> This example shows how a [https:..."</p>
<p><b>New page</b></p><div><center><br />
<gallery widths=400px heights=400px><br />
File:Example_render_aztec_code.png | Rendered Aztec Code from this example<br />
</gallery><br />
</center><br />
<br />
This example shows how a [https://en.wikipedia.org/wiki/Aztec_Code Aztec Codes] can be rendered into an image. Its easy to adapt the approach here for just about any file format, e.g. PDF. <br />
<br />
Example Code:<br />
* [https://github.com/lessthanoptimal/BoofCV/blob/v0.41/examples/src/main/java/boofcv/examples/fiducial/ExampleRenderAztecCode.java ExampleRenderAztecCode.java]<br />
<br />
Concepts:<br />
* Fiducials<br />
* Micro QR Codes<br />
<br />
Relevant Examples/Tutorials:<br />
* [[Tutorial_QRCodes|Tutorial QR Codes]]<br />
* [[Example_Detect_Aztec_Code|Detecting Aztec Codes]]<br />
<br />
= Example Code =<br />
<br />
<syntaxhighlight lang="java"><br />
/**<br />
* An easy-to-use API is provided for creating your own Aztec Code marker. You can render it as an image or PDF<br />
* document.<br />
*<br />
* @author Peter Abeles<br />
* @see MicroQrCodeGenerator<br />
*/<br />
public class ExampleRenderAztecCode {<br />
public static void main( String[] args ) {<br />
// Create a marker to render. Almost everything about how the marker is constructed can be manually specified<br />
// or you can let it automatically select everything<br />
AztecCode marker = new AztecEncoder().addAutomatic("Code 2D!").fixate();<br />
// NOTE: The final function you call must be fixate(), that's how it knows it's done<br />
<br />
// Render the marker as an image. It's also possible to render as a PDF or your own custom format<br />
GrayU8 rendered = AztecGenerator.renderImage(/* pixel per square */ 10, /* border squares */ 1, marker);<br />
<br />
// Convert it to a BufferedImage for display purposes<br />
BufferedImage output = ConvertBufferedImage.convertTo(rendered, null);<br />
<br />
// You can also save it to disk by uncommenting the line below<br />
// UtilImageIO.saveImage(output, "aztec.png");<br />
<br />
// Display the rendered marker<br />
ShowImages.showWindow(output, "Rendered Aztec Code", true);<br />
}<br />
}<br />
</syntaxhighlight></div>Peter