use of boofcv.alg.fiducial.microqr.MicroQrCodeEncoder in project BoofCV by lessthanoptimal.
the class BenchmarkMicroQrCodeDetector 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);
MicroQrCode qr1 = new MicroQrCodeEncoder().addAutomatic("1").fixate();
MicroQrCode qr2 = new MicroQrCodeEncoder().addAutomatic("ALPHA NUMERIC 123").fixate();
GrayU8 image1 = MicroQrCodeGenerator.renderImage(5, 2, qr1);
GrayU8 image2 = MicroQrCodeGenerator.renderImage(5, 2, qr2);
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.01, rand.nextGaussian() * 0.01, 1.0, rand.nextGaussian() * 0.5, rand.nextGaussian() * 0.5).apply();
images.add(distorted);
}
}
use of boofcv.alg.fiducial.microqr.MicroQrCodeEncoder in project BoofCV by lessthanoptimal.
the class ExampleRenderMicroQrCode method main.
public static void main(String[] args) {
// Uses a flow pattern to specify the QR Code. You can control all aspects of the Micro QR
// like specifying the version, mask, and message types or let it select all of that for you.
MicroQrCode qr = new MicroQrCodeEncoder().setError(MicroQrCode.ErrorLevel.L).addAutomatic("Test ん鞠").fixate();
// NOTE: The final function you call must be fixate(), that's how it knows it's done
// Render the QR as an image. It's also possible to render as a PDF or your own custom format
GrayU8 rendered = MicroQrCodeGenerator.renderImage(/* pixel per module */
10, /* border modules*/
1, qr);
// 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, "microqr.png");
// Display the image
ShowImages.showWindow(output, "Rendered Micro QR Code", true);
}
use of boofcv.alg.fiducial.microqr.MicroQrCodeEncoder in project BoofCV by lessthanoptimal.
the class TestMicroQrCodeDetectorPnP method renderFiducial.
@Override
public GrayF32 renderFiducial() {
MicroQrCode qr = new MicroQrCodeEncoder().addAutomatic("THE MESSAGE").fixate();
int width = MicroQrCode.totalModules(qr.version) * 6;
var engine = new FiducialImageEngine();
// interpolation gets messed up if it touches the border. plus scale is relative
engine.configure(1, width);
var generator = new MicroQrCodeGenerator();
generator.markerWidth = width;
generator.setRender(engine);
generator.render(qr);
return engine.getGrayF32();
}
Aggregations