use of boofcv.abst.fiducial.SquareImage_to_FiducialDetector in project BoofCV by lessthanoptimal.
the class FiducialTrackerDemoApp method openExample.
@Override
public void openExample(Object o) {
// stop everything because all the data structures about about to be changed
stopAllInputProcessing();
PathLabel example = (PathLabel) o;
String name = example.label;
String videoName = example.getPath();
String seperator = System.getProperty("file.separator");
String path = videoName.substring(0, videoName.lastIndexOf(seperator.charAt(0)));
ConfigThreshold configThreshold = ConfigThreshold.local(ThresholdType.LOCAL_MEAN, 21);
boolean stability = true;
if (name.compareTo(SQUARE_NUMBER) == 0) {
detector = FactoryFiducial.squareBinary(new ConfigFiducialBinary(0.1), configThreshold, imageClass);
} else if (name.compareTo(SQUARE_PICTURE) == 0) {
double length = 0.1;
detector = FactoryFiducial.squareImage(new ConfigFiducialImage(), configThreshold, imageClass);
SquareImage_to_FiducialDetector<I> d = (SquareImage_to_FiducialDetector<I>) detector;
String pathImg = new File(path, "../patterns").getPath();
List<String> names = new ArrayList<>();
names.add("chicken.png");
names.add("yinyang.png");
for (String foo : names) {
BufferedImage img = media.openImage(new File(pathImg, foo).getPath());
if (img == null)
throw new RuntimeException("Can't find file " + new File(pathImg, foo).getPath());
d.addPatternImage(ConvertBufferedImage.convertFromSingle(img, null, imageClass), 125, length);
}
} else if (name.compareTo(CALIB_CHESS) == 0) {
detector = FactoryFiducial.calibChessboard(new ConfigChessboard(7, 5, 0.03), imageClass);
} else if (name.compareTo(CALIB_SQUARE_GRID) == 0) {
detector = FactoryFiducial.calibSquareGrid(new ConfigSquareGrid(4, 3, 0.03, 0.03), imageClass);
} else if (name.compareTo(CALIB_SQUARE_BINARY_GRID) == 0) {
File configFile = new File(path, "description_4x3_3x3_4cm_2cm.txt");
try {
ConfigSquareGridBinary config = ConfigSquareGridBinary.parseSimple(new BufferedReader(new FileReader(configFile)));
detector = FactoryFiducial.calibSquareGridBinary(config, imageClass);
} catch (IOException e) {
throw new RuntimeException(e);
}
} else if (name.compareTo(CALIB_CIRCLE_HEXAGONAL_GRID) == 0) {
stability = false;
detector = FactoryFiducial.calibCircleHexagonalGrid(new ConfigCircleHexagonalGrid(24, 28, 1, 1.2), imageClass);
} else if (name.compareTo(CALIB_CIRCLE_REGULAR_GRID) == 0) {
stability = false;
detector = FactoryFiducial.calibCircleRegularGrid(new ConfigCircleRegularGrid(10, 8, 1.5, 2.5), imageClass);
} else {
throw new RuntimeException("Unknown selection");
}
controls.setShowStability(stability);
intrinsic = CalibrationIO.load(media.openFile(path + "/intrinsic.yaml"));
detector.setLensDistortion(new LensDistortionRadialTangential(intrinsic), intrinsic.width, intrinsic.height);
fiducialInfo.clear();
// give it some initial values so that it doesn't look like there is huge errors right off the bat
stabilityMax.location = 0.01;
stabilityMax.orientation = 0.02;
openVideo(false, videoName);
}
Aggregations