public class BinaryPolygonDetector<T extends boofcv.struct.image.ImageGray>
extends java.lang.Object
Detects 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 RefineBinaryPolygon.
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
BinaryPolygonDetector.Info |
| Modifier and Type | Field and Description |
|---|---|
protected boofcv.struct.distort.PixelTransform_F32 |
distToUndist |
protected boofcv.struct.distort.PixelTransform_F32 |
undistToDist |
| 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.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<boofcv.alg.filter.binary.Contour> |
getAllContours() |
boofcv.struct.distort.PixelTransform_F32 |
getDistToUndist() |
double |
getEdgeThreshold() |
org.ddogleg.struct.FastQueue<georegression.struct.shapes.Polygon2D_F64> |
getFoundPolygons() |
java.lang.Class<T> |
getInputType() |
boofcv.struct.image.GrayS32 |
getLabeled() |
int |
getMaximumSides() |
int |
getMinimumSides() |
org.ddogleg.struct.FastQueue<BinaryPolygonDetector.Info> |
getPolygonInfo()
Returns additional information on the polygon
|
RefineBinaryPolygon<T> |
getRefinePolygon() |
boofcv.struct.distort.PixelTransform_F32 |
getUndistToDist() |
java.util.List<boofcv.alg.filter.binary.Contour> |
getUsedContours() |
boolean |
isCheckEdgeBefore() |
boolean |
isConvex() |
boolean |
isOutputClockwise() |
void |
process(T gray,
boofcv.struct.image.GrayU8 binary)
Examines the undistorted gray scake input image for squares.
|
void |
setCheckEdgeBefore(boolean checkEdgeBefore)
If set to true it will prune using polygons using their edge intensity before sub-pixel optimization.
|
void |
setConvex(boolean convex) |
void |
setEdgeThreshold(double edgeThreshold) |
void |
setHelper(PolygonHelper helper) |
void |
setLensDistortion(int width,
int height,
boofcv.struct.distort.PixelTransform_F32 distToUndist,
boofcv.struct.distort.PixelTransform_F32 undistToDist)
Specifies transforms which can be used to change coordinates from distorted to undistorted and the opposite
coordinates.
|
void |
setNumberOfSides(int min,
int max) |
void |
setRefinePolygon(RefineBinaryPolygon<T> refinePolygon) |
void |
setVerbose(boolean verbose) |
protected boolean |
touchesBorder(java.util.List<georegression.struct.point.Point2D_I32> contour)
Checks to see if some part of the contour touches the image border.
|
protected boofcv.struct.distort.PixelTransform_F32 distToUndist
protected boofcv.struct.distort.PixelTransform_F32 undistToDist
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)
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. See MinimizeEnergyPruneedgeThreshold - Polygons with an edge intensity less than this are discarded.inputType - Type of input image it's processingpublic void setLensDistortion(int width,
int height,
boofcv.struct.distort.PixelTransform_F32 distToUndist,
boofcv.struct.distort.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.
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.public void process(T gray, boofcv.struct.image.GrayU8 binary)
gray - Input imageprotected final boolean touchesBorder(java.util.List<georegression.struct.point.Point2D_I32> contour)
public void setHelper(PolygonHelper helper)
public boolean isConvex()
public void setConvex(boolean convex)
public boofcv.struct.image.GrayS32 getLabeled()
public boolean isOutputClockwise()
public org.ddogleg.struct.FastQueue<georegression.struct.shapes.Polygon2D_F64> getFoundPolygons()
public java.util.List<boofcv.alg.filter.binary.Contour> getUsedContours()
public java.util.List<boofcv.alg.filter.binary.Contour> getAllContours()
public java.lang.Class<T> getInputType()
public void setNumberOfSides(int min,
int max)
public int getMinimumSides()
public int getMaximumSides()
public void setVerbose(boolean verbose)
public boolean isCheckEdgeBefore()
public RefineBinaryPolygon<T> getRefinePolygon()
public void setRefinePolygon(RefineBinaryPolygon<T> refinePolygon)
public double getEdgeThreshold()
public void setEdgeThreshold(double edgeThreshold)
public boofcv.struct.distort.PixelTransform_F32 getDistToUndist()
public boofcv.struct.distort.PixelTransform_F32 getUndistToDist()
public org.ddogleg.struct.FastQueue<BinaryPolygonDetector.Info> getPolygonInfo()
public void setCheckEdgeBefore(boolean checkEdgeBefore)
checkEdgeBefore - true for checking before and false for after.