Difference between revisions of "Example Detect Calibration Target"

From BoofCV
Jump to navigationJump to search
m
m
Line 7: Line 7:
BoofCV provides fully automated calibration target detection.  Once detected calibration point locations are returned with a high level of precision. While intended for camera calibration, they can also be used for other applications, such as augmented reality.  In this example it is demonstrated how to detect different types of grid based targets.
BoofCV provides fully automated calibration target detection.  Once detected calibration point locations are returned with a high level of precision. While intended for camera calibration, they can also be used for other applications, such as augmented reality.  In this example it is demonstrated how to detect different types of grid based targets.


Example File: [https://github.com/lessthanoptimal/BoofCV/blob/v0.23/examples/src/boofcv/examples/calibration/ExampleDetectCalibrationPoints.java ExampleDetectCalibrationPoints.java]
Example File: [https://github.com/lessthanoptimal/BoofCV/blob/v0.25/examples/src/boofcv/examples/calibration/ExampleDetectCalibrationPoints.java ExampleDetectCalibrationPoints.java]


Concepts:
Concepts:
* Calibration targets
* Fiducials / Markers
 
* Calibration
Relevant Applets:
* [[Applet_Calibrate_Detect_Square| Detect Square Grid Calibration Target]]
* [[Applet_Calibrate_Detect_Chess| Detect Chessboard Calibration Target]]


Related Examples/Tutorials:
Related Examples/Tutorials:
Line 41: Line 38:


// To select different types of detectors add or remove comments below
// To select different types of detectors add or remove comments below
CalibrationDetector detector;
DetectorFiducialCalibration detector;


// For chessboard targets, tune RADIUS parameter for your images
// For chessboard targets, tune RADIUS parameter for your images
// detector = FactoryCalibrationTarget.detectorSquareGrid(new ConfigSquareGrid(4, 3, 30, 30));
// detector = FactoryCalibrationTarget.squareGrid(new ConfigSquareGrid(4, 3, 30, 30));
detector = FactoryCalibrationTarget.detectorChessboard( new ConfigChessboard(7, 5, 30));
detector = FactoryFiducialCalibration.chessboard( new ConfigChessboard(7, 5, 30));


// process the image and check for failure condition
// process the image and check for failure condition
Line 56: Line 53:
// render and display the results
// render and display the results
Graphics2D g2 = orig.createGraphics();
Graphics2D g2 = orig.createGraphics();
for( CalibrationObservation.Point p : set.points )
for( PointIndex2D_F64 p : set.points )
VisualizeFeatures.drawPoint(g2,(int)p.pixel.x,(int)p.pixel.y,3,Color.RED);
VisualizeFeatures.drawPoint(g2,p.x,p.y,3,Color.RED, true);


ShowImages.showWindow(orig,"Calibration Points", true);
ShowImages.showWindow(orig,"Calibration Points", true);

Revision as of 13:41, 1 December 2016

BoofCV provides fully automated calibration target detection. Once detected calibration point locations are returned with a high level of precision. While intended for camera calibration, they can also be used for other applications, such as augmented reality. In this example it is demonstrated how to detect different types of grid based targets.

Example File: ExampleDetectCalibrationPoints.java

Concepts:

  • Fiducials / Markers
  • Calibration

Related Examples/Tutorials:

Example Code

/**
 * Example that demonstrates how to detect calibration targets.  Calibration points are found on the
 * targets to a high level of precision.  It is assumed that a single image only shows a single target
 * and that the entire target is visible.  If these conditions are not meet then the target is likely
 * to not be detected.
 *
 * @author Peter Abeles
 */
public class ExampleDetectCalibrationPoints {

	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);
	}
}