use of boofcv.factory.filter.binary.ConfigThreshold in project BoofCV by lessthanoptimal.
the class DetectFiducialSquareBinaryApp method createDetector.
protected void createDetector(boolean initializing) {
if (!initializing)
BoofSwingUtil.checkGuiThread();
synchronized (lockProcessing) {
ConfigThreshold configThresh = controls.polygonPanel.getThresholdPanel().createConfig();
ConfigFiducialBinary configFid = controls.getConfig();
final InputToBinary<GrayF32> binary = FactoryThresholdBinary.threshold(configThresh, GrayF32.class);
final DetectPolygonBinaryGrayRefine<GrayF32> squareDetector = FactoryShapeDetector.polygon(configFid.squareDetector, GrayF32.class);
detector = new Detector(configFid, binary, squareDetector);
}
}
use of boofcv.factory.filter.binary.ConfigThreshold 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);
}
use of boofcv.factory.filter.binary.ConfigThreshold in project BoofCV by lessthanoptimal.
the class DetectBlackEllipseApp method imageThresholdUpdated.
@Override
public void imageThresholdUpdated() {
DetectEllipseControlPanel controls = (DetectEllipseControlPanel) DetectBlackEllipseApp.this.controls;
ConfigThreshold config = controls.getThreshold().createConfig();
synchronized (this) {
inputToBinary = FactoryThresholdBinary.threshold(config, imageClass);
}
reprocessImageOnly();
}
use of boofcv.factory.filter.binary.ConfigThreshold in project BoofCV by lessthanoptimal.
the class ThresholdControlPanel method createConfig.
public ConfigThreshold createConfig() {
ConfigThreshold config;
if (type == ThresholdType.BLOCK_MIN_MAX) {
ConfigThresholdBlockMinMax _config = new ConfigThresholdBlockMinMax();
_config.minimumSpread = minimumSpread;
config = _config;
} else if (type == ThresholdType.BLOCK_OTSU || type == ThresholdType.LOCAL_OTSU) {
ConfigThresholdLocalOtsu _config = new ConfigThresholdLocalOtsu();
_config.tuning = otsuTuning;
_config.useOtsu2 = useOtsu2;
config = _config;
} else {
config = new ConfigThreshold();
config.fixedThreshold = fixedThreshold;
}
config.type = type;
config.scale = scale;
config.down = down;
config.width = regionWidth.copy();
config.savolaK = savolaK;
config.minPixelValue = minPixelValue;
config.maxPixelValue = maxPixelValue;
config.thresholdFromLocalBlocks = thresholdLocalBlocks;
return config;
}
use of boofcv.factory.filter.binary.ConfigThreshold in project BoofCV by lessthanoptimal.
the class DetectPolylineApp method imageThresholdUpdated.
@Override
public void imageThresholdUpdated() {
PolylineAppControlPanel controls = (PolylineAppControlPanel) DetectPolylineApp.this.controls;
ConfigThreshold config = controls.getThreshold().createConfig();
synchronized (this) {
inputToBinary = FactoryThresholdBinary.threshold(config, imageClass);
}
reprocessImageOnly();
}
Aggregations