Search in sources :

Example 1 with ConfigThreshold

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);
    }
}
Also used : ConfigThreshold(boofcv.factory.filter.binary.ConfigThreshold) ConfigFiducialBinary(boofcv.factory.fiducial.ConfigFiducialBinary) GrayF32(boofcv.struct.image.GrayF32) FactoryShapeDetector(boofcv.factory.shape.FactoryShapeDetector)

Example 2 with ConfigThreshold

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);
}
Also used : ConfigFiducialBinary(boofcv.factory.fiducial.ConfigFiducialBinary) IOException(java.io.IOException) ConfigFiducialImage(boofcv.factory.fiducial.ConfigFiducialImage) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) ConfigThreshold(boofcv.factory.filter.binary.ConfigThreshold) LensDistortionRadialTangential(boofcv.alg.distort.radtan.LensDistortionRadialTangential) SquareImage_to_FiducialDetector(boofcv.abst.fiducial.SquareImage_to_FiducialDetector) PathLabel(boofcv.io.PathLabel) BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) List(java.util.List) FileReader(java.io.FileReader) File(java.io.File)

Example 3 with ConfigThreshold

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();
}
Also used : ConfigThreshold(boofcv.factory.filter.binary.ConfigThreshold)

Example 4 with ConfigThreshold

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;
}
Also used : ConfigThreshold(boofcv.factory.filter.binary.ConfigThreshold) ConfigThresholdLocalOtsu(boofcv.factory.filter.binary.ConfigThresholdLocalOtsu) ConfigThresholdBlockMinMax(boofcv.factory.filter.binary.ConfigThresholdBlockMinMax)

Example 5 with ConfigThreshold

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();
}
Also used : ConfigThreshold(boofcv.factory.filter.binary.ConfigThreshold)

Aggregations

ConfigThreshold (boofcv.factory.filter.binary.ConfigThreshold)11 ConfigFiducialBinary (boofcv.factory.fiducial.ConfigFiducialBinary)3 GrayU8 (boofcv.struct.image.GrayU8)3 ConfigFiducialImage (boofcv.factory.fiducial.ConfigFiducialImage)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 BufferedImage (java.awt.image.BufferedImage)2 ArrayList (java.util.ArrayList)2 SquareImage_to_FiducialDetector (boofcv.abst.fiducial.SquareImage_to_FiducialDetector)1 InputToBinary (boofcv.abst.filter.binary.InputToBinary)1 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)1 ConfigThresholdBlockMinMax (boofcv.factory.filter.binary.ConfigThresholdBlockMinMax)1 ConfigThresholdLocalOtsu (boofcv.factory.filter.binary.ConfigThresholdLocalOtsu)1 FactoryShapeDetector (boofcv.factory.shape.FactoryShapeDetector)1 PathLabel (boofcv.io.PathLabel)1 GrayF32 (boofcv.struct.image.GrayF32)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 List (java.util.List)1