use of boofcv.factory.fiducial.ConfigMicroQrCode 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);
}
Aggregations