use of boofcv.alg.fiducial.aztec.AztecCode in project BoofCV by lessthanoptimal.
the class GenericAztecCodeDetectorChecks method multipleMarkers.
/**
* See if it can detect multiple fiducials in the image at the same time
*/
@Test
void multipleMarkers() {
AztecCodeDetector<GrayF32> detector = createDetector();
CameraPinholeBrown model = CalibrationIO.load(getClass().getResource("calib/pinhole_radial.yaml"));
SimulatePlanarWorld simulator = new SimulatePlanarWorld();
simulator.setCamera(model);
simulator.resetScene();
Se3_F64 markerToWorld0 = new Se3_F64();
Se3_F64 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<AztecCode> detections = detector.getDetections();
assertEquals(2, detections.size());
}
use of boofcv.alg.fiducial.aztec.AztecCode in project BoofCV by lessthanoptimal.
the class AztecCodePreciseDetector method process.
@Override
public void process(T gray) {
// Reset and initialize
allMarkers.reset();
detected.clear();
failed.clear();
// Detect finder patterns
inputToBinary.process(gray, binary);
detectorPyramids.process(gray, binary);
// Attempt to decode candidate markers
List<AztecPyramid> pyramids = detectorPyramids.getFound().toList();
if (verbose != null)
verbose.println("Total pyramids found: " + pyramids.size());
for (int locatorIdx = 0; locatorIdx < pyramids.size(); locatorIdx++) {
AztecPyramid pyramid = pyramids.get(locatorIdx);
if (verbose != null)
verbose.println("Considering pyramid at: " + pyramid.get(0).center);
AztecCode marker = allMarkers.grow();
if (decoder.process(pyramid, gray, marker)) {
detected.add(marker);
} else {
failed.add(marker);
}
}
}
use of boofcv.alg.fiducial.aztec.AztecCode in project BoofCV by lessthanoptimal.
the class BenchmarkAztecCodeDetector 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);
AztecCode marker1 = new AztecEncoder().addAutomatic("small").fixate();
AztecCode marker2 = new AztecEncoder().addAutomatic("Much Larger Than the Oth9er!!#").fixate();
GrayU8 image1 = AztecGenerator.renderImage(5, 0, marker1);
GrayU8 image2 = AztecGenerator.renderImage(5, 0, marker2);
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.1, rand.nextGaussian() * 0.01, rand.nextGaussian() * 0.01, 1.0 + rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.5, rand.nextGaussian() * 0.5).apply();
images.add(distorted);
}
}
use of boofcv.alg.fiducial.aztec.AztecCode in project BoofCV by lessthanoptimal.
the class TestCreateAztecCodeDocument method two.
@Test
void two() throws IOException {
createDocument("-t http://boofcv.org -t second -p LETTER -w 5 -o target.pdf");
BufferedImage image = loadPDF();
GrayF32 gray = ConvertBufferedImage.convertFrom(image, (GrayF32) null);
// ShowImages.showBlocking(gray,"Rendered", 10_000, true);
AztecCodeDetector<GrayF32> detector = FactoryFiducial.aztec(null, GrayF32.class);
detector.process(gray);
List<AztecCode> found = detector.getDetections();
assertEquals(2, found.size());
checkFound(found, "http://boofcv.org", "second");
}
use of boofcv.alg.fiducial.aztec.AztecCode in project BoofCV by lessthanoptimal.
the class DetectAztecCodeMessagePanel method updateList.
public void updateList(List<AztecCode> detected, List<AztecCode> 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++) {
AztecCode marker = detected.get(i);
String shortName = marker.structure.toString().substring(0, 4);
model.addElement(String.format("%4s L=%02d %.10s", shortName, marker.dataLayers, marker.message));
this.detected.add(marker.copy());
}
this.failures.clear();
for (int i = 0; i < failures.size(); i++) {
AztecCode marker = failures.get(i);
String shortName = marker.structure.toString().substring(0, 4);
model.addElement(String.format("%4s L=%02d %s", shortName, marker.dataLayers, marker.failure));
this.failures.add(marker.copy());
}
listDetected.invalidate();
listDetected.repaint();
textArea.setText("");
this.listDetected.addListSelectionListener(this);
}
Aggregations