Difference between revisions of "Example Fiducial Square Image"
From BoofCV
Jump to navigationJump to search (Created page with "<center> <gallery widths=280px heights=240px> file:Example_fiducial_image.jpg | Rendered 3D flat squares on top of fiducials </gallery> </center> Demonstration how to detect...") |
m |
||
Line 14: | Line 14: | ||
* Pose estimation | * Pose estimation | ||
Relevant Tutorials: | Relevant Examples/Tutorials: | ||
* [[Tutorial_Fiducials|Tutorial Fiducials]] | * [[Tutorial_Fiducials|Tutorial Fiducials]] | ||
* [[Example_Fiducial_Square_Binary|Example Fiducial Square Binary]] | |||
* [[Example_Calibration_Target_Pose|Example Fiducial Calibration Target]] | |||
Relevant Applets: | Relevant Applets: |
Revision as of 15:43, 15 September 2014
Demonstration how to detect square image fiducials. After the fiducial detector has been created a description of each image it detects is passed in. These images are converted into binary images and resized if needed. A large number of unique fiducials can be detected with a linear growth in computational time.
Example Code:
Concepts:
- Fiducials
- Pose estimation
Relevant Examples/Tutorials:
Relevant Applets:
Example Code
/**
* Detects square binary fiducials inside an image, writes out there pose, and visualizes a virtual flat cube
* above them in the input image.
*
* @author Peter Abeles
*/
public class ExampleFiducialImage {
public static void main(String[] args) {
String directory = "../data/applet/fiducial/image/";
String imageName = "image0000.jpg";
// String imageName = "image0001.jpg";
// String imageName = "image0002.jpg";
// load the lens distortion parameters and the input image
IntrinsicParameters param = UtilIO.loadXML(directory + "intrinsic.xml");
BufferedImage input = UtilImageIO.loadImage(directory + imageName);
ImageFloat32 original = ConvertBufferedImage.convertFrom(input, true, ImageType.single(ImageFloat32.class));
// Detect the fiducial
SquareImage_to_FiducialDetector<ImageFloat32> detector = FactoryFiducial.
squareImageRobust(new ConfigFiducialImage(0.1), 6, ImageFloat32.class);
// squareImageFast(new ConfigFiducialImage(0.1), 100, ImageFloat32.class);
// give it a description of all the targets
ImageFloat32 dog = UtilImageIO.loadImage(directory + "dog.png",ImageFloat32.class);
detector.addTarget(dog, 125);
// uncomment to detect the text target
ImageFloat32 text = UtilImageIO.loadImage(directory + "text.png",ImageFloat32.class);
detector.addTarget(text, 125);
detector.setIntrinsic(param);
detector.detect(original);
// print the results
Graphics2D g2 = input.createGraphics();
Se3_F64 targetToSensor = new Se3_F64();
for (int i = 0; i < detector.totalFound(); i++) {
System.out.println("Target ID = "+detector.getId(i));
detector.getFiducialToWorld(i, targetToSensor);
System.out.println("Location:");
System.out.println(targetToSensor);
VisualizeFiducial.drawCube(targetToSensor,param,0.1,g2);
}
ShowImages.showWindow(input,"Fiducials");
}
}