use of boofcv.abst.geo.calibration.DetectMultiFiducialCalibration in project BoofCV by lessthanoptimal.
the class GenericDetectMultiFiducialCalibrationChecks method basicPinhole.
@Test
void basicPinhole() {
DetectMultiFiducialCalibration detector = createDetector();
// CameraPinholeBrown model = CalibrationIO.load(getClass().getResource("pinhole_radial.yaml"));
CameraPinholeBrown model = new CameraPinholeBrown().fsetK(600, 600, 0, 400, 400, 800, 800);
SimulatePlanarWorld simulator = new SimulatePlanarWorld();
simulator.setCamera(model);
DogArray<List<PointIndex2D_F64>> markerPoints = new DogArray<>(ArrayList::new);
for (int i = 0; i < Math.min(2, detector.getTotalUniqueMarkers()); i++) {
GrayF32 pattern = renderPattern(i, markerPoints.grow());
Se3_F64 markerToWorld = SpecialEuclideanOps_F64.eulerXyz((-0.5 + i) * 0.32, 0, .5, 0, Math.PI, 0, null);
simulator.addSurface(markerToWorld, simulatedTargetWidth, pattern);
}
// marker systems since that requires encoding that should remove that ambiguity
for (int cameraOriIdx = 0; cameraOriIdx < 10; cameraOriIdx++) {
double roll = 2.0 * Math.PI * cameraOriIdx / 10;
simulator.setWorldToCamera(SpecialEuclideanOps_F64.eulerXyz(0, 0, 0, 0, 0, roll, null));
simulator.render();
// Process the image and see if it detected everything
detector.process(simulator.getOutput());
// ShowImages.showWindow(simulator.getOutput(), "Rotated "+cameraOriIdx);
// BoofMiscOps.sleep(2_000);
// Number of markers which are not anonymous
int totalIdentified = 0;
for (int i = 0; i < detector.getDetectionCount(); i++) {
if (detector.getMarkerID(i) >= 0)
totalIdentified++;
}
if (visualizeFailures && 2 != totalIdentified) {
UtilImageIO.saveImage(simulator.getOutput(), "failed.png");
ShowImages.showWindow(simulator.getOutput(), "Simulated");
BoofMiscOps.sleep(10_000);
}
assertEquals(2, totalIdentified);
for (int i = 0; i < detector.getDetectionCount(); i++) {
int markerID = detector.getMarkerID(i);
// Ignore anonymous markers
if (markerID < 0)
continue;
// See if it detected the expected number of calibration points on the marker
assertEquals(markerPoints.get(markerID).size(), detector.getDetectedPoints(i).size());
// TODO check the actual coordinates
}
}
}
Aggregations