All Downloads are FREE. Search and download functionalities are using the official Maven repository.

boofcv.factory.shape.ConfigPolygonFromContour Maven / Gradle / Ivy

Go to download

BoofCV is an open source Java library for real-time computer vision and robotics applications.

There is a newer version: 1.1.7
Show newest version
/*
 * Copyright (c) 2011-2020, Peter Abeles. All Rights Reserved.
 *
 * This file is part of BoofCV (http://boofcv.org).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package boofcv.factory.shape;

import boofcv.abst.shapes.polyline.BaseConfigPolyline;
import boofcv.abst.shapes.polyline.ConfigPolylineSplitMerge;
import boofcv.alg.shapes.edge.EdgeIntensityPolygon;
import boofcv.struct.ConfigLength;
import boofcv.struct.Configuration;
import boofcv.struct.ConnectRule;

/**
 * Configuration for {@link boofcv.alg.shapes.polygon.DetectPolygonFromContour}
 *
 * @author Peter Abeles
 */
public class ConfigPolygonFromContour implements Configuration {

	/**
	 * If false then polygons which touch the image border are pruned
	 */
	public boolean canTouchBorder = false;

	/**
	 * Connect rule for contour finding in binary image.
	 */
	public ConnectRule contourRule = ConnectRule.FOUR;

	/**
	 * Configuration for fitting a polygon to the contour.
	 */
	public BaseConfigPolyline contourToPoly = new ConfigPolylineSplitMerge();

	/**
	 * 

* The minimum allowed edge intensity for a shape. Used to remove false positives generated by noise, which * is especially common when using a local threshold during binarization. *

* *

Set to zero to disable.

* * @see EdgeIntensityPolygon */ public double minimumEdgeIntensity = 6.0; /** * Tangential distance away in pixels from the contour that the edge intensity is sampled. */ public double tangentEdgeIntensity = 2.5; /** * Specifies the minimum allowed contour length. Relative lengths will be relative with to the image's * width and height. */ public ConfigLength minimumContour = ConfigLength.relative(0.05,4); /** * Will the found polygons be in clockwise order? */ public boolean clockwise = true; /** * Specifies the number of sides in the polygon and uses default settings for everything else */ public ConfigPolygonFromContour(int minimumSides, int maximumSides) { contourToPoly.minimumSides = minimumSides; contourToPoly.maximumSides = maximumSides; } public ConfigPolygonFromContour(boolean clockwise, int minimumSides, int maximumSides) { contourToPoly.minimumSides = minimumSides; contourToPoly.maximumSides = maximumSides; this.clockwise = clockwise; } public ConfigPolygonFromContour(){} public void setTo( ConfigPolygonFromContour src ) { this.canTouchBorder = src.canTouchBorder; this.contourRule = src.contourRule; this.contourToPoly.setTo(src.contourToPoly); this.minimumEdgeIntensity = src.minimumEdgeIntensity; this.tangentEdgeIntensity = src.tangentEdgeIntensity; this.minimumContour.setTo(src.minimumContour); this.clockwise = src.clockwise; } @Override public void checkValidity() { minimumContour.checkValidity(); } @Override public String toString() { return "ConfigPolygonFromContour{" + " contourToPoly=" + contourToPoly + ", minimumEdgeIntensity=" + minimumEdgeIntensity + ", tangentEdgeIntensity=" + tangentEdgeIntensity + ", minimumContour=" + minimumContour + ", clockwise=" + clockwise + '}'; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy