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);
}
}
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);
}
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);
}
}
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");
}
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();
}
}
Aggregations