Search in sources :

Example 1 with MicroQrCodeEncoder

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);
    }
}
Also used : Random(java.util.Random) FDistort(boofcv.abst.distort.FDistort) MicroQrCode(boofcv.alg.fiducial.microqr.MicroQrCode) GrayU8(boofcv.struct.image.GrayU8) MicroQrCodeEncoder(boofcv.alg.fiducial.microqr.MicroQrCodeEncoder)

Example 2 with MicroQrCodeEncoder

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);
}
Also used : MicroQrCode(boofcv.alg.fiducial.microqr.MicroQrCode) GrayU8(boofcv.struct.image.GrayU8) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) MicroQrCodeEncoder(boofcv.alg.fiducial.microqr.MicroQrCodeEncoder)

Example 3 with MicroQrCodeEncoder

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();
}
Also used : FiducialImageEngine(boofcv.alg.drawing.FiducialImageEngine) MicroQrCode(boofcv.alg.fiducial.microqr.MicroQrCode) MicroQrCodeGenerator(boofcv.alg.fiducial.microqr.MicroQrCodeGenerator) MicroQrCodeEncoder(boofcv.alg.fiducial.microqr.MicroQrCodeEncoder)

Aggregations

MicroQrCode (boofcv.alg.fiducial.microqr.MicroQrCode)3 MicroQrCodeEncoder (boofcv.alg.fiducial.microqr.MicroQrCodeEncoder)3 GrayU8 (boofcv.struct.image.GrayU8)2 FDistort (boofcv.abst.distort.FDistort)1 FiducialImageEngine (boofcv.alg.drawing.FiducialImageEngine)1 MicroQrCodeGenerator (boofcv.alg.fiducial.microqr.MicroQrCodeGenerator)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 BufferedImage (java.awt.image.BufferedImage)1 Random (java.util.Random)1