use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.
the class CalibratePinholePlanarGuiApp method main.
public static void main(String[] args) {
DetectorFiducialCalibration detector = // FactoryFiducialCalibration.squareGrid(new ConfigSquareGrid(4,3,30,30));
FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
// FactoryFiducialCalibration.circleHexagonalGrid(new ConfigCircleHexagonalGrid(5, 8, 1, 6));
List<String> images;
// images = UtilIO.directoryList(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_Square"),"frame");
images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_Chess"), "frame");
// images = UtilIO.directoryList(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_CircleHexagonal"),"image");
// images = UtilIO.directoryList(UtilIO.pathExample("calibration/mono/PULNiX_CCD_6mm_Zhang"),"CalibIm");
// images = UtilIO.directoryList(UtilIO.pathExample("calibration//stereo/Bumblebee2_Square"),"left");
CalibratePinholePlanarGuiApp app = new CalibratePinholePlanarGuiApp();
app.configure(detector, images, 2, false);
JFrame frame = new JFrame("Pinhole Calribation with Planar Targets");
frame.add(app, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
app.process("intrinsic.yaml");
}
use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.
the class CalibrateStereoPlanarGuiApp method main.
public static void main(String[] args) {
DetectorFiducialCalibration detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
// FactoryCalibrationTarget.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Chess");
// String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Square");
List<String> leftImages = UtilIO.listByPrefix(directory, "left");
List<String> rightImages = UtilIO.listByPrefix(directory, "right");
Collections.sort(leftImages);
Collections.sort(rightImages);
List<File> leftFiles = new ArrayList<>();
List<File> rightFiles = new ArrayList<>();
for (String s : leftImages) {
leftFiles.add(new File(s));
}
for (String s : rightImages) {
rightFiles.add(new File(s));
}
CalibrateStereoPlanarGuiApp app = new CalibrateStereoPlanarGuiApp();
app.configure(detector, 2, false, true, leftFiles, rightFiles);
ShowImages.showWindow(app, "Planar Stereo Calibration", true);
app.process("stereo.yaml");
}
use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.
the class GenericPlanarCalibrationDetectorChecks method dataNotRecycled.
/**
* Make sure new instances of calibration points are returned each time
*/
@Test
public void dataNotRecycled() {
for (Object layout : targetConfigs) {
DetectorFiducialCalibration detector = createDetector(layout);
GrayF32 original = renderEasy(layout, null);
assertTrue(detector.process(original));
CalibrationObservation found0 = detector.getDetectedPoints();
assertTrue(detector.process(original));
CalibrationObservation found1 = detector.getDetectedPoints();
assertEquals(found0.size(), found1.size());
assertTrue(found0 != found1);
for (int i = 0; i < found0.size(); i++) {
PointIndex2D_F64 p0 = found0.get(i);
for (int j = 0; j < found1.size(); j++) {
PointIndex2D_F64 p1 = found1.get(j);
assertFalse(p0 == p1);
}
}
}
}
use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.
the class GenericPlanarCalibrationDetectorChecks method pinhole_radial_fullview.
/**
* Simulated scene using a pinhole camera model with radial distortion. Entire target is visible
*/
@Test
public void pinhole_radial_fullview() {
CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("pinhole_radial.yaml"));
SimulatePlanarWorld simulator = new SimulatePlanarWorld();
simulator.setCamera(model);
List<Point2D_F64> locations2D = new ArrayList<>();
GrayF32 pattern = new GrayF32(1, 1);
for (int i = 0; i < targetConfigs.size(); i++) {
// System.out.println("*---------- Configuration "+i);
failedToDetect = 0;
DetectorFiducialCalibration detector = createDetector(targetConfigs.get(i));
renderTarget(targetConfigs.get(i), simulatedTargetWidth, pattern, locations2D);
simulator.resetScene();
Se3_F64 markerToWorld = new Se3_F64();
simulator.addTarget(markerToWorld, simulatedTargetWidth, pattern);
// up close exploding - center
markerToWorld.T.set(0, 0, 0.5);
checkRenderedResults(detector, simulator, locations2D);
// farther away centered
markerToWorld.T.set(0, 0, 1);
checkRenderedResults(detector, simulator, locations2D);
markerToWorld.T.set(-0.33, 0, 1);
checkRenderedResults(detector, simulator, locations2D);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -1, 0, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -1, 0.8, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
markerToWorld.T.set(-0.33, 0.33, 1);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -1, 0.8, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
markerToWorld.T.set(0, -0.20, 1);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.8, -1, 0.8, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.8, -1, 1.8, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
markerToWorld.T.set(0, -0.15, 1);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.2, -1, 2.4, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
}
assertEquals(0, failedToDetect);
}
use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.
the class ExampleCalibrateFisheye method main.
public static void main(String[] args) {
DetectorFiducialCalibration detector;
List<String> images;
// Circle based calibration targets not not recommended because the sever lens distortion will change
// the apparent location of tangent points.
// Square Grid example
// detector = FactoryFiducialCalibration.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
// images = UtilIO.listAll(UtilIO.pathExample("calibration/fisheye/square_grid"));
// Chessboard Example
detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
images = UtilIO.listAll(UtilIO.pathExample("calibration/fisheye/chessboard"));
// Declare and setup the calibration algorithm
CalibrateMonoPlanar calibrationAlg = new CalibrateMonoPlanar(detector.getLayout());
// tell it type type of target and which parameters to estimate
calibrationAlg.configureUniversalOmni(true, 2, false);
for (String n : images) {
BufferedImage input = UtilImageIO.loadImage(n);
if (input != null) {
GrayF32 image = ConvertBufferedImage.convertFrom(input, (GrayF32) null);
if (detector.process(image)) {
calibrationAlg.addImage(detector.getDetectedPoints().copy());
} else {
System.err.println("Failed to detect target in " + n);
}
}
}
// process and compute intrinsic parameters
CameraUniversalOmni intrinsic = calibrationAlg.process();
// save results to a file and print out
CalibrationIO.save(intrinsic, "fisheye.yaml");
calibrationAlg.printStatistics();
System.out.println();
System.out.println("--- Intrinsic Parameters ---");
System.out.println();
intrinsic.print();
}
Aggregations