use of boofcv.abst.geo.calibration.DetectSingleFiducialCalibration in project BoofCV by lessthanoptimal.
the class GenericDetectSingleFiducialCalibrationChecks method dataNotRecycled.
/**
* Make sure new instances of calibration points are returned each time
*/
@Test
void dataNotRecycled() {
for (ConfigGridDimen layout : targetConfigs) {
DetectSingleFiducialCalibration 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());
assertNotSame(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);
assertNotSame(p0, p1);
}
}
}
}
use of boofcv.abst.geo.calibration.DetectSingleFiducialCalibration in project BoofCV by lessthanoptimal.
the class GenericDetectSingleFiducialCalibrationChecks method pinhole_radial_fullview.
/**
* Simulated scene using a pinhole camera model with radial distortion. Entire target is visible
*/
@Test
void pinhole_radial_fullview() {
CameraPinholeBrown 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;
DetectSingleFiducialCalibration detector = createDetector(targetConfigs.get(i));
renderTarget(targetConfigs.get(i), simulatedTargetWidth, pattern, locations2D);
simulator.resetScene();
Se3_F64 markerToWorld = new Se3_F64();
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, Math.PI, 0, markerToWorld.R);
simulator.addSurface(markerToWorld, simulatedTargetWidth, pattern);
// up close exploding - center
markerToWorld.T.setTo(0, 0, 0.5);
checkRenderedResults(detector, simulator, locations2D);
// farther away centered
markerToWorld.T.setTo(0, 0, 1);
checkRenderedResults(detector, simulator, locations2D);
markerToWorld.T.setTo(-0.33, 0, 1);
checkRenderedResults(detector, simulator, locations2D);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, Math.PI - 1, 0, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, Math.PI - 1, 0.8, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
markerToWorld.T.setTo(-0.33, 0.33, 1);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, Math.PI - 1, 0.8, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
markerToWorld.T.setTo(0, -0.20, 1);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.8, Math.PI, 0.8, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.8, Math.PI, 1.8, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
markerToWorld.T.setTo(0, -0.15, 1);
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.2, Math.PI, 2.4, markerToWorld.getR());
checkRenderedResults(detector, simulator, locations2D);
}
assertEquals(0, failedToDetect);
}
use of boofcv.abst.geo.calibration.DetectSingleFiducialCalibration in project BoofCV by lessthanoptimal.
the class ExampleCalibrateMonocular method main.
public static void main(String[] args) {
DetectSingleFiducialCalibration detector;
List<String> images;
// Regular Circle Example
// detector = FactoryFiducialCalibration.circleRegularGrid(null, new ConfigGridDimen(/*numRows*/ 8, /*numCols*/ 10, 1.5, 2.5));
// images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_CircleRegular"),"image", null);
// Hexagonal Circle Example
// detector = FactoryFiducialCalibration.circleHexagonalGrid(null, new ConfigGridDimen(/*numRows*/ 24, /*numCols*/ 28, 1, 1.2));
// images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_CircleHexagonal"),"image", null);
// Square Grid example
// detector = FactoryFiducialCalibration.squareGrid(null, new ConfigGridDimen(/*numRows*/ 4, /*numCols*/ 3, 30, 30));
// images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/stereo/Bumblebee2_Square"),"left", null);
// ECoCheck Example
// detector = new MultiToSingleFiducialCalibration(FactoryFiducialCalibration.
// ecocheck(null, ConfigECoCheckMarkers.
// singleShape(/*numRows*/ 9, /*numCols*/ 7, /*num markers*/ 1, /* square size */ 30)));
// images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/stereo/Zed_ecocheck"), "left", null);
// Chessboard Example
detector = FactoryFiducialCalibration.chessboardX(null, new ConfigGridDimen(/*numRows*/
7, /*numCols*/
5, /*shapeSize*/
30));
images = UtilIO.listByPrefix(UtilIO.pathExample("calibration/stereo/Bumblebee2_Chess"), "left", null);
// Declare and setup the calibration algorithm
CalibrateMonoPlanar calibrationAlg = new CalibrateMonoPlanar(detector.getLayout());
// tell it type type of target and which intrinsic parameters to estimate
calibrationAlg.configurePinhole(/*assumeZeroSkew*/
true, /*numRadialParam*/
2, /*includeTangential*/
false);
for (String n : images) {
BufferedImage input = UtilImageIO.loadImageNotNull(n);
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
CameraPinholeBrown intrinsic = calibrationAlg.process();
// save results to a file and print out
CalibrationIO.save(intrinsic, "intrinsic.yaml");
calibrationAlg.printStatistics(System.out);
System.out.println();
System.out.println("--- Intrinsic Parameters ---");
System.out.println();
intrinsic.print();
}
use of boofcv.abst.geo.calibration.DetectSingleFiducialCalibration in project BoofCV by lessthanoptimal.
the class ExampleCalibrateFisheye method main.
public static void main(String[] args) {
DetectSingleFiducialCalibration detector;
// Circle based calibration targets are not recommended because the sever lens distortion will change
// the apparent location of tangent points.
// Square Grid example
// detector = FactoryFiducialCalibration.squareGrid(null, new ConfigGridDimen(/*rows*/ 4, /*cols*/ 3, /*size*/ 30, /*space*/ 30));
// images = UtilIO.listAll(UtilIO.pathExample("calibration/fisheye/square_grid"));
// Chessboard Example
detector = FactoryFiducialCalibration.chessboardX(null, new ConfigGridDimen(/*rows*/
7, /*cols*/
5, /*size*/
30));
List<String> images = UtilIO.listAll(UtilIO.pathExample("calibration/fisheye/chessboard"));
// Declare and setup the calibration algorithm
var calibrationAlg = new CalibrateMonoPlanar(detector.getLayout());
// Specify the camera model to use. Here are a few examples.
//
calibrationAlg.configureUniversalOmni(/*zeroSkew*/
true, /*radial*/
2, /*tangential*/
false);
for (String n : images) {
BufferedImage input = UtilImageIO.loadImage(n);
if (input == null)
continue;
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
CameraModel intrinsic = calibrationAlg.process();
// save results to a file and print out
CalibrationIO.save(intrinsic, "fisheye.yaml");
calibrationAlg.printStatistics(System.out);
System.out.println();
System.out.println("--- Intrinsic Parameters ---");
System.out.println();
intrinsic.print();
}
use of boofcv.abst.geo.calibration.DetectSingleFiducialCalibration 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.loadImageNotNull(directory + "/left01.jpg");
GrayF32 input = ConvertBufferedImage.convertFrom(orig, (GrayF32) null);
// To select different types of detectors add or remove comments below
DetectSingleFiducialCalibration detector;
// For chessboard targets, tune RADIUS parameter for your images
// detector = FactoryFiducialCalibration.squareGrid(null, new ConfigGridDimen(4, 3, 30, 30));
detector = FactoryFiducialCalibration.chessboardX(null, new ConfigGridDimen(/*rows*/
7, /*cols*/
5, /*shape size*/
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.p.x, p.p.y, 3, Color.RED, true);
ShowImages.showWindow(orig, "Calibration Points", true);
}
Aggregations