Class BinaryPolygonDetector<T extends ImageGray>
- java.lang.Object
-
- boofcv.alg.shapes.polygon.BinaryPolygonDetector<T>
-
public class BinaryPolygonDetector<T extends ImageGray> extends java.lang.ObjectDetects convex polygons with the specified number of sides in an image. Shapes are assumed to be black shapes against a white background, allowing for thresholding to be used. Subpixel refinement is done using the provided implementation of
Processing Steps:RefineBinaryPolygon.- First the input a gray scale image and a binarized version of it.
- The contours of black blobs are found.
- From the contours polygons are fitted and refined to pixel accuracy.
- (Optional) Sub-pixel refinement of the polygon's edges and/or corners.
The returned polygons will encompass the entire black polygon. Here is a simple example in 1D. If all pixels are white, but pixels ranging from 5 to 10, inclusive, then the returned boundaries would be 5.0 to 11.0. This means that coordinates 5.0 ≤ x < 11.0 are all black. 11.0 is included, but note that the entire pixel 11 is white.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classBinaryPolygonDetector.Info
-
Constructor Summary
Constructors Constructor and Description BinaryPolygonDetector(int minSides, int maxSides, SplitMergeLineFitLoop contourToPolygon, RefineBinaryPolygon<T> refinePolygon, double minContourFraction, boolean outputClockwise, boolean convex, boolean touchBorder, double splitPenalty, double edgeThreshold, java.lang.Class<T> inputType)Configures the detector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.util.List<Contour>getAllContours()PixelTransform_F32getDistToUndist()doublegetEdgeThreshold()FastQueue<Polygon2D_F64>getFoundPolygons()java.lang.Class<T>getInputType()GrayS32getLabeled()intgetMaximumSides()intgetMinimumSides()FastQueue<BinaryPolygonDetector.Info>getPolygonInfo()Returns additional information on the polygonRefineBinaryPolygon<T>getRefinePolygon()PixelTransform_F32getUndistToDist()java.util.List<Contour>getUsedContours()booleanisCheckEdgeBefore()booleanisConvex()booleanisOutputClockwise()voidprocess(T gray, GrayU8 binary)Examines the undistorted gray scake input image for squares.voidsetCheckEdgeBefore(boolean checkEdgeBefore)If set to true it will prune using polygons using their edge intensity before sub-pixel optimization.voidsetConvex(boolean convex)voidsetEdgeThreshold(double edgeThreshold)voidsetHelper(PolygonHelper helper)voidsetLensDistortion(int width, int height, PixelTransform_F32 distToUndist, PixelTransform_F32 undistToDist)Specifies transforms which can be used to change coordinates from distorted to undistorted and the opposite coordinates.voidsetNumberOfSides(int min, int max)voidsetRefinePolygon(RefineBinaryPolygon<T> refinePolygon)voidsetVerbose(boolean verbose)
-
-
-
Constructor Detail
-
BinaryPolygonDetector
public BinaryPolygonDetector(int minSides, int maxSides, SplitMergeLineFitLoop contourToPolygon, RefineBinaryPolygon<T> refinePolygon, double minContourFraction, boolean outputClockwise, boolean convex, boolean touchBorder, double splitPenalty, double edgeThreshold, java.lang.Class<T> inputType)Configures the detector.- Parameters:
minSides- minimum number of sidesmaxSides- maximum number of sidescontourToPolygon- Fits a crude polygon to the shape's binary contourrefinePolygon- (Optional) Refines the polygon's lines. Set to null to skip stepminContourFraction- Size of minimum contour as a fraction of the input image's width. Try 0.23outputClockwise- If true then the order of the output polygons will be in clockwise orderconvex- If true it will only return convex shapestouchBorder- if true then shapes which touch the image border are allowedsplitPenalty- Penalty given to a line segment while splitting. SeeMinimizeEnergyPruneedgeThreshold- Polygons with an edge intensity less than this are discarded.inputType- Type of input image it's processing
-
-
Method Detail
-
setLensDistortion
public void setLensDistortion(int width, int height, PixelTransform_F32 distToUndist, PixelTransform_F32 undistToDist)Specifies transforms which can be used to change coordinates from distorted to undistorted and the opposite coordinates. The undistorted image is never explicitly created.
WARNING: The undistorted image must have the same bounds as the distorted input image. This is because several of the bounds checks use the image shape. This are simplified greatly by this assumption.
- Parameters:
width- Input image width. Used in sanity check only.height- Input image height. Used in sanity check only.distToUndist- Transform from distorted to undistorted image.undistToDist- Transform from undistorted to distorted image.
-
process
public void process(T gray, GrayU8 binary)
Examines the undistorted gray scake input image for squares.- Parameters:
gray- Input image
-
setHelper
public void setHelper(PolygonHelper helper)
-
isConvex
public boolean isConvex()
-
setConvex
public void setConvex(boolean convex)
-
getLabeled
public GrayS32 getLabeled()
-
isOutputClockwise
public boolean isOutputClockwise()
-
getFoundPolygons
public FastQueue<Polygon2D_F64> getFoundPolygons()
-
getUsedContours
public java.util.List<Contour> getUsedContours()
-
getAllContours
public java.util.List<Contour> getAllContours()
-
getInputType
public java.lang.Class<T> getInputType()
-
setNumberOfSides
public void setNumberOfSides(int min, int max)
-
getMinimumSides
public int getMinimumSides()
-
getMaximumSides
public int getMaximumSides()
-
setVerbose
public void setVerbose(boolean verbose)
-
isCheckEdgeBefore
public boolean isCheckEdgeBefore()
-
getRefinePolygon
public RefineBinaryPolygon<T> getRefinePolygon()
-
setRefinePolygon
public void setRefinePolygon(RefineBinaryPolygon<T> refinePolygon)
-
getEdgeThreshold
public double getEdgeThreshold()
-
setEdgeThreshold
public void setEdgeThreshold(double edgeThreshold)
-
getDistToUndist
public PixelTransform_F32 getDistToUndist()
-
getUndistToDist
public PixelTransform_F32 getUndistToDist()
-
getPolygonInfo
public FastQueue<BinaryPolygonDetector.Info> getPolygonInfo()
Returns additional information on the polygon
-
setCheckEdgeBefore
public void setCheckEdgeBefore(boolean checkEdgeBefore)
If set to true it will prune using polygons using their edge intensity before sub-pixel optimization. This should only be set to false if the initial edge is known to be off by a bit, like with a chessboard.- Parameters:
checkEdgeBefore- true for checking before and false for after.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG