public class BinaryPolygonConvexDetector<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.
Processing Steps:
Subpixel refinement is done using the provided RefinePolygonLineToImage and RefinePolygonCornersToImage.
If straight lines are straight, as is the case with images with lens distortion removes, then the line based
refinement will tend to produce better results. If lens distortion is present then the corner sub-pixel algorithm
is more likely to produce better results.
NOTE: If both refinement methods are used then corner is applied first followed by line.
NOTE: A binary image is not processed as input because the gray-scale image is used in the sub-pixel line/corner
refinement.
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 | Field and Description |
|---|---|
protected boofcv.struct.distort.PixelTransform_F32 |
toDistorted |
protected boofcv.struct.distort.PixelTransform_F32 |
toUndistorted |
| Constructor and Description |
|---|
BinaryPolygonConvexDetector(int[] polygonSides,
SplitMergeLineFitLoop contourToPolygon,
PolygonEdgeScore differenceScore,
RefinePolygonLineToImage<T> refineLine,
RefinePolygonCornersToImage<T> refineCorner,
double minContourFraction,
double splitDistanceFraction,
boolean outputClockwise,
java.lang.Class<T> inputType)
Configures the detector.
|
| Modifier and Type | Method and Description |
|---|---|
org.ddogleg.struct.FastQueue<georegression.struct.shapes.Polygon2D_F64> |
getFound() |
java.util.List<boofcv.alg.filter.binary.Contour> |
getFoundContours() |
java.lang.Class<T> |
getInputType() |
boofcv.struct.image.ImageSInt32 |
getLabeled() |
int[] |
getNumberOfSides() |
boolean |
isCheckEdgeBefore() |
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 |
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[] numberOfSides) |
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 BinaryPolygonConvexDetector(int[] polygonSides,
SplitMergeLineFitLoop contourToPolygon,
PolygonEdgeScore differenceScore,
RefinePolygonLineToImage<T> refineLine,
RefinePolygonCornersToImage<T> refineCorner,
double minContourFraction,
double splitDistanceFraction,
boolean outputClockwise,
java.lang.Class<T> inputType)
polygonSides - Number of lines in the polygoncontourToPolygon - 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.refineLine - (Optional) Refines the polygon's lines. Set to null to skip steprefineCorner - (Optional) Refines the polygon's corners. Set to null to skip stepminContourFraction - Size of minimum contour as a fraction of the input image's width. Try 0.23splitDistanceFraction - Number of pixels as a fraction of contour length to split a new line in
SplitMergeLineFitLoop. Try 0.03outputClockwise - If true then the order of the output polygons will be in clockwise orderinputType - 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 boofcv.struct.image.ImageSInt32 getLabeled()
public boolean isOutputClockwise()
public org.ddogleg.struct.FastQueue<georegression.struct.shapes.Polygon2D_F64> getFound()
public java.util.List<boofcv.alg.filter.binary.Contour> getFoundContours()
public java.lang.Class<T> getInputType()
public void setNumberOfSides(int[] numberOfSides)
public int[] getNumberOfSides()
public void setVerbose(boolean verbose)
public boolean isCheckEdgeBefore()
public void setCheckEdgeBefore(boolean checkEdgeBefore)
checkEdgeBefore - true for checking before and false for after.