use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.
the class ExampleCalibrateMonocular method main.
public static void main(String[] args) {
DetectorFiducialCalibration detector;
List<String> images;
// Regular Circle Example
// detector = FactoryFiducialCalibration.circleRegularGrid(new ConfigCircleRegularGrid(8, 10, 1.5, 2.5));
// images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_CircleRegular"),"image");
// Hexagonal Circle Example
// detector = FactoryFiducialCalibration.circleHexagonalGrid(new ConfigCircleHexagonalGrid(24, 28, 1, 1.2));
// images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_CircleHexagonal"),"image");
// Square Grid example
// detector = FactoryFiducialCalibration.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
// images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/stereo/Bumblebee2_Square"),"left");
// Chessboard Example
detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/stereo/Bumblebee2_Chess"), "left");
// Declare and setup the calibration algorithm
CalibrateMonoPlanar calibrationAlg = new CalibrateMonoPlanar(detector.getLayout());
// tell it type type of target and which parameters to estimate
calibrationAlg.configurePinhole(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
CameraPinholeRadial intrinsic = calibrationAlg.process();
// save results to a file and print out
CalibrationIO.save(intrinsic, "intrinsic.yaml");
calibrationAlg.printStatistics();
System.out.println();
System.out.println("--- Intrinsic Parameters ---");
System.out.println();
intrinsic.print();
}
use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.
the class ExampleDetectCalibrationPoints method main.
public static void main(String[] args) {
// load the test image
// String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Square");
String directory = UtilIO.pathExample("calibration/stereo/Bumblebee2_Chess");
BufferedImage orig = UtilImageIO.loadImage(directory + "/left01.jpg");
GrayF32 input = ConvertBufferedImage.convertFrom(orig, (GrayF32) null);
// To select different types of detectors add or remove comments below
DetectorFiducialCalibration detector;
// For chessboard targets, tune RADIUS parameter for your images
// detector = FactoryCalibrationTarget.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(7, 5, 30));
// process the image and check for failure condition
if (!detector.process(input))
throw new RuntimeException("Target detection failed!");
// Ordered observations of calibration points on the target
CalibrationObservation set = detector.getDetectedPoints();
// render and display the results
Graphics2D g2 = orig.createGraphics();
for (PointIndex2D_F64 p : set.points) VisualizeFeatures.drawPoint(g2, p.x, p.y, 3, Color.RED, true);
ShowImages.showWindow(orig, "Calibration Points", true);
}
use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.
the class GenericPlanarCalibrationDetectorChecks method checkDetectionsResetOnFailure.
/**
* First call something was detected, second call nothing was detected. it should return an empty list
*/
@Test
public void checkDetectionsResetOnFailure() {
DetectorFiducialCalibration detector = createDetector(targetConfigs.get(0));
GrayF32 original = renderEasy(targetConfigs.get(0), null);
detector.process(original);
assertTrue(detector.getDetectedPoints().size() > 0);
detector.process(new GrayF32(300, 400));
assertTrue(detector.getDetectedPoints() != null);
assertTrue(detector.getDetectedPoints().size() == 0);
}
use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.
the class GenericPlanarCalibrationDetectorChecks method fisheye_fullview.
/**
* See if it can detect targets distorted by fisheye lens. Entire target is always seen
*/
@Test
public void fisheye_fullview() {
CameraUniversalOmni model = CalibrationIO.load(getClass().getResource("fisheye.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++) {
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);
failedToDetect = 0;
for (int j = 0; j < fisheye_poses.size(); j++) {
// System.out.println("fisheye pose = "+j);
markerToWorld.set(fisheye_poses.get(j));
checkRenderedResults(detector, simulator, locations2D);
}
}
assertTrue(failedToDetect <= fisheyeAllowedFails);
}
use of boofcv.abst.geo.calibration.DetectorFiducialCalibration in project BoofCV by lessthanoptimal.
the class GenericPlanarCalibrationDetectorChecks method checkDetectionsNonnull.
/**
* Nothing was detected. make sure it doesn't return null.
*/
@Test
public void checkDetectionsNonnull() {
for (Object layout : targetConfigs) {
DetectorFiducialCalibration detector = createDetector(layout);
detector.process(new GrayF32(300, 400));
assertTrue(detector.getDetectedPoints() != null);
assertTrue(detector.getDetectedPoints().size() == 0);
}
}
Aggregations