use of boofcv.alg.fiducial.microqr.MicroQrCode in project BoofCV by lessthanoptimal.
the class DetectMicroQrMessagePanel method updateList.
public void updateList(List<MicroQrCode> detected, List<MicroQrCode> failures) {
BoofSwingUtil.checkGuiThread();
this.listDetected.removeListSelectionListener(this);
DefaultListModel<String> model = (DefaultListModel) listDetected.getModel();
model.clear();
this.detected.clear();
for (int i = 0; i < detected.size(); i++) {
MicroQrCode qr = detected.get(i);
model.addElement(String.format("v%2d Mode %.5s %.10s", qr.version, qr.mode.toString(), qr.message));
this.detected.add(qr.clone());
}
this.failures.clear();
for (int i = 0; i < failures.size(); i++) {
MicroQrCode qr = failures.get(i);
model.addElement(String.format("v%2d Cause: %s", qr.version, qr.failureCause.toString()));
this.failures.add(qr.clone());
}
listDetected.invalidate();
listDetected.repaint();
textArea.setText("");
this.listDetected.addListSelectionListener(this);
}
use of boofcv.alg.fiducial.microqr.MicroQrCode in project BoofCV by lessthanoptimal.
the class ExampleDetectMicroQrCode method main.
public static void main(String[] args) {
BufferedImage input = UtilImageIO.loadImageNotNull(UtilIO.pathExample("fiducial/microqr/image01.jpg"));
GrayU8 gray = ConvertBufferedImage.convertFrom(input, (GrayU8) null);
var config = new ConfigMicroQrCode();
// config.considerTransposed = false; // by default, it will consider incorrectly encoded markers. Faster if false
MicroQrCodeDetector<GrayU8> detector = FactoryFiducial.microqr(config, GrayU8.class);
detector.process(gray);
// Gets a list of all the qr codes it could successfully detect and decode
List<MicroQrCode> detections = detector.getDetections();
Graphics2D g2 = input.createGraphics();
// in large images the line can be too thin
int strokeWidth = Math.max(4, input.getWidth() / 200);
g2.setColor(Color.GREEN);
g2.setStroke(new BasicStroke(strokeWidth));
for (MicroQrCode qr : detections) {
// The message encoded in the marker
System.out.println("message: '" + qr.message + "'");
// Visualize its location in the image
VisualizeShapes.drawPolygon(qr.bounds, true, 1, g2);
}
// List of objects it thinks might be a QR Code but failed for various reasons
List<MicroQrCode> failures = detector.getFailures();
g2.setColor(Color.RED);
for (MicroQrCode qr : failures) {
// If the 'cause' is ERROR_CORRECTION or later it might a real QR Code
if (qr.failureCause.ordinal() < QrCode.Failure.ERROR_CORRECTION.ordinal())
continue;
VisualizeShapes.drawPolygon(qr.bounds, true, 1, g2);
}
ShowImages.showWindow(input, "Example Micro QR Codes", true);
}
use of boofcv.alg.fiducial.microqr.MicroQrCode in project BoofCV by lessthanoptimal.
the class CreateMicroQrDocumentPDF method render.
@Override
protected void render(int markerIndex) {
MicroQrCode qr = markers.get(markerIndex % markers.size());
g.render(qr);
}
use of boofcv.alg.fiducial.microqr.MicroQrCode 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.MicroQrCode in project BoofCV by lessthanoptimal.
the class TestCreateMicroQrDocument method gridAndCustomDocument.
@Test
void gridAndCustomDocument() throws IOException {
createDocument("-t 1234567 -t second -p 14cm:14cm --GridFill -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(4, found.size());
checkFound(detector.getDetections(), "1234567", "second");
}
Aggregations