public class BinaryPolygonDetector<T extends boofcv.struct.image.ImageSingleBand>
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 |
toDistorted |
protected boofcv.struct.distort.PixelTransform_F32 |
toUndistorted |
| Constructor and Description |
|---|
BinaryPolygonDetector(int minSides,
int maxSides,
SplitMergeLineFitLoop contourToPolygon,
PolygonEdgeScore differenceScore,
RefineBinaryPolygon<T> refinePolygon,
double minContourFraction,
boolean outputClockwise,
boolean convex,
boolean touchBorder,
double splitPenalty,
java.lang.Class<T> inputType)
Configures the detector.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<boofcv.alg.filter.binary.Contour> |
getAllContours() |
org.ddogleg.struct.FastQueue<georegression.struct.shapes.Polygon2D_F64> |
getFoundPolygons() |
java.lang.Class<T> |
getInputType() |
boofcv.struct.image.ImageSInt32 |
getLabeled() |
int |
getMaximumSides() |
int |
getMinimumSides() |
RefineBinaryPolygon<T> |
getRefinePolygon() |
java.util.List<boofcv.alg.filter.binary.Contour> |
getUsedContours() |
boolean |
isCheckEdgeBefore() |
boolean |
isConvex() |
boolean |
isOutputClockwise() |
void |
process(T gray,
boofcv.struct.image.ImageUInt8 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 |
setHelper(PolygonHelper helper) |
void |
setLensDistortion(int width,
int height,
boofcv.struct.distort.PixelTransform_F32 toUndistorted,
boofcv.struct.distort.PixelTransform_F32 toDistorted)
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 toUndistorted
protected boofcv.struct.distort.PixelTransform_F32 toDistorted
public BinaryPolygonDetector(int minSides,
int maxSides,
SplitMergeLineFitLoop contourToPolygon,
PolygonEdgeScore differenceScore,
RefineBinaryPolygon<T> refinePolygon,
double minContourFraction,
boolean outputClockwise,
boolean convex,
boolean touchBorder,
double splitPenalty,
java.lang.Class<T> inputType)
minSides - minimum number of sidesmaxSides - maximum number of sidescontourToPolygon - Fits a crude polygon to the shape's binary contourdifferenceScore - Used to remove false positives by computing the difference along the polygon's edges
If null then this test is skipped.refinePolygon - (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 MinimizeEnergyPruneinputType - Type of input image it's processingpublic void setLensDistortion(int width,
int height,
boofcv.struct.distort.PixelTransform_F32 toUndistorted,
boofcv.struct.distort.PixelTransform_F32 toDistorted)
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.toUndistorted - Transform from undistorted to distorted image.toDistorted - Transform from distorted to undistorted image.public void process(T gray, boofcv.struct.image.ImageUInt8 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.ImageSInt32 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 void setCheckEdgeBefore(boolean checkEdgeBefore)
checkEdgeBefore - true for checking before and false for after.