Search in sources :

Example 1 with MicroQrCode

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

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

the class MicroQrCodeDetectorPnP method getCenter.

@Override
public void getCenter(int which, Point2D_F64 location) {
    // Use the marker's homography to determine where the center is since there are no landmarks
    // that can be used
    MicroQrCode qr = detector.getDetections().get(which);
    // Number of modules wide the marker is
    int halfModules = qr.getNumberOfModules() / 2;
    HomographyPointOps_F64.transform(qr.Hinv, halfModules + 0.5, halfModules + 0.5, location);
}
Also used : MicroQrCode(boofcv.alg.fiducial.microqr.MicroQrCode)

Example 3 with MicroQrCode

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

the class BatchScanMicroQrCodes method processFile.

private void processFile(File f) throws UnsupportedEncodingException {
    BufferedImage buffered = UtilImageIO.loadImage(f.getAbsolutePath());
    if (buffered == null) {
        System.err.println("Can't open " + f.getPath());
        return;
    }
    if (listener != null) {
        listener.batchUpdate(f.getName());
    }
    ConvertBufferedImage.convertFrom(buffered, gray);
    scanner.process(gray);
    output.printf("%d %s\n", scanner.getDetections().size(), f.getPath());
    for (MicroQrCode qr : scanner.getDetections()) {
        output.println(URLEncoder.encode(qr.message, "UTF-8"));
    }
    total++;
    if (total % 50 == 0) {
        if (verbose)
            System.out.println("processed " + total);
    }
}
Also used : MicroQrCode(boofcv.alg.fiducial.microqr.MicroQrCode) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 4 with MicroQrCode

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

the class TestCreateMicroQrDocument method single.

@Test
void single() throws IOException {
    createDocument("-t 1234567 -p LETTER -w 5 -o target.pdf");
    BufferedImage image = loadPDF();
    GrayF32 gray = new GrayF32(image.getWidth(), image.getHeight());
    ConvertBufferedImage.convertFrom(image, gray);
    // ShowImages.showWindow(image,"Rendered", true);
    // BoofMiscOps.sleep(10000);
    // UtilImageIO.saveImage(image,"test.png");
    MicroQrCodeDetector<GrayF32> detector = FactoryFiducial.microqr(null, GrayF32.class);
    detector.process(gray);
    List<MicroQrCode> found = detector.getDetections();
    checkFound(found, "1234567");
}
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 5 with MicroQrCode

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

the class DetectMicroQrMessagePanel method valueChanged.

@Override
public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting())
        return;
    if (e.getSource() == listDetected) {
        int selected = listDetected.getSelectedIndex();
        if (selected == -1)
            return;
        boolean failed = selected >= detected.size();
        if (failed) {
            selected -= detected.size();
            MicroQrCode qr = failures.get(selected);
            listener.selectedMarkerInList(selected, true);
            setMarkerMessageText(qr, true);
        } else {
            listener.selectedMarkerInList(selected, false);
            MicroQrCode qr = detected.get(selected);
            setMarkerMessageText(qr, false);
        }
        textArea.invalidate();
    }
}
Also used : MicroQrCode(boofcv.alg.fiducial.microqr.MicroQrCode)

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