Search in sources :

Example 11 with MicroQrCode

use of boofcv.alg.fiducial.microqr.MicroQrCode in project BoofCV by lessthanoptimal.

the class TestCreateMicroQrDocument method two.

@Test
void two() throws IOException {
    createDocument("-t 1234567 -t second -p LETTER -w 5 -o target.pdf");
    BufferedImage image = loadPDF();
    var gray = new GrayF32(image.getWidth(), image.getHeight());
    ConvertBufferedImage.convertFrom(image, gray);
    // ShowImages.showWindow(image,"Rendered", true);
    // BoofMiscOps.sleep(10000);
    MicroQrCodeDetector<GrayF32> detector = FactoryFiducial.microqr(null, GrayF32.class);
    detector.process(gray);
    List<MicroQrCode> found = detector.getDetections();
    assertEquals(2, found.size());
    checkFound(found, "1234567", "second");
}
Also used : GrayF32(boofcv.struct.image.GrayF32) MicroQrCode(boofcv.alg.fiducial.microqr.MicroQrCode) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) Test(org.junit.jupiter.api.Test)

Example 12 with MicroQrCode

use of boofcv.alg.fiducial.microqr.MicroQrCode 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)

Example 13 with MicroQrCode

use of boofcv.alg.fiducial.microqr.MicroQrCode in project BoofCV by lessthanoptimal.

the class GenericMicroQrCodeDetectorChecks method renderAndCheck.

private void renderAndCheck(MicroQrCodeDetector<GrayF32> detector, SimulatePlanarWorld simulator) {
    simulator.render();
    detector.process(simulator.getOutput());
    if (display) {
        ShowImages.showWindow(simulator.getOutput(), ShowImages.Colorization.MAGNITUDE, "Foo", true);
        BoofMiscOps.sleep(200);
        UtilImageIO.saveImage(simulator.getOutput(), "microqr_rendered.png");
    }
    List<MicroQrCode> detections = detector.getDetections();
    assertEquals(1, detections.size());
    MicroQrCode qr = detections.get(0);
    assertEquals(message, qr.message);
}
Also used : MicroQrCode(boofcv.alg.fiducial.microqr.MicroQrCode)

Example 14 with MicroQrCode

use of boofcv.alg.fiducial.microqr.MicroQrCode in project BoofCV by lessthanoptimal.

the class GenericMicroQrCodeDetectorChecks method multipleMarkers.

/**
 * See if it can detect multiple fiducials in the image at the same time
 */
@Test
void multipleMarkers() {
    MicroQrCodeDetector<GrayF32> detector = createDetector();
    CameraPinholeBrown model = CalibrationIO.load(getClass().getResource("calib/pinhole_radial.yaml"));
    var simulator = new SimulatePlanarWorld();
    simulator.setCamera(model);
    simulator.resetScene();
    var markerToWorld0 = new Se3_F64();
    var markerToWorld1 = new Se3_F64();
    simulator.addSurface(markerToWorld0, simulatedTargetWidth, generateMarker());
    simulator.addSurface(markerToWorld1, simulatedTargetWidth, generateMarker());
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, Math.PI, 0, markerToWorld0.R);
    markerToWorld0.T.setTo(0.2, 0, 0.6);
    ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, Math.PI, 0, markerToWorld1.R);
    markerToWorld1.T.setTo(-0.2, 0, 0.6);
    simulator.render();
    detector.process(simulator.getOutput());
    if (display) {
        ShowImages.showWindow(simulator.getOutput(), ShowImages.Colorization.MAGNITUDE, "Foo", true);
        BoofMiscOps.sleep(10000);
    }
    List<MicroQrCode> detections = detector.getDetections();
    assertEquals(2, detections.size());
}
Also used : SimulatePlanarWorld(boofcv.simulation.SimulatePlanarWorld) GrayF32(boofcv.struct.image.GrayF32) CameraPinholeBrown(boofcv.struct.calib.CameraPinholeBrown) MicroQrCode(boofcv.alg.fiducial.microqr.MicroQrCode) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.jupiter.api.Test)

Aggregations

MicroQrCode (boofcv.alg.fiducial.microqr.MicroQrCode)14 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)6 BufferedImage (java.awt.image.BufferedImage)6 GrayF32 (boofcv.struct.image.GrayF32)4 Test (org.junit.jupiter.api.Test)4 MicroQrCodeEncoder (boofcv.alg.fiducial.microqr.MicroQrCodeEncoder)3 GrayU8 (boofcv.struct.image.GrayU8)3 FDistort (boofcv.abst.distort.FDistort)1 FiducialImageEngine (boofcv.alg.drawing.FiducialImageEngine)1 MicroQrCodeGenerator (boofcv.alg.fiducial.microqr.MicroQrCodeGenerator)1 ConfigMicroQrCode (boofcv.factory.fiducial.ConfigMicroQrCode)1 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)1 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)1 Se3_F64 (georegression.struct.se.Se3_F64)1 Random (java.util.Random)1