public class DetectPolygonFromContour<T extends boofcv.struct.image.ImageGray<T>>
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 RefinePolygonToGray.
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.
Notes:
| Modifier and Type | Class and Description |
|---|---|
static class |
DetectPolygonFromContour.Info |
| Modifier and Type | Field and Description |
|---|---|
protected boofcv.struct.distort.PixelTransform2_F32 |
distToUndist |
protected boofcv.struct.distort.PixelTransform2_F32 |
undistToDist |
| Modifier | Constructor and Description |
|---|---|
protected |
DetectPolygonFromContour()
For unit testing
|
|
DetectPolygonFromContour(PointsToPolyline contourToPolyline,
boofcv.struct.ConfigLength minimumContour,
boolean outputClockwise,
boolean touchBorder,
double contourEdgeThreshold,
double tangentEdgeIntensity,
boofcv.abst.filter.binary.BinaryContourFinder contourFinder,
java.lang.Class<T> inputType)
Configures the detector.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearLensDistortion()
Discard previously set lens distortion models
|
static void |
flip(int[] a,
int N) |
java.util.List<boofcv.alg.filter.binary.ContourPacked> |
getAllContours() |
java.util.List<georegression.struct.point.Point2D_I32> |
getContour(DetectPolygonFromContour.Info info)
Returns the undistorted contour for a shape.
|
double |
getContourEdgeThreshold() |
boofcv.abst.filter.binary.BinaryContourFinder |
getContourFinder() |
boofcv.struct.distort.PixelTransform2_F32 |
getDistToUndist() |
org.ddogleg.struct.FastQueue<DetectPolygonFromContour.Info> |
getFound()
Returns additional information on the polygon
|
java.lang.Class<T> |
getInputType() |
int |
getMaximumSides() |
double |
getMilliContour() |
double |
getMilliShapes() |
int |
getMinimumSides() |
boofcv.struct.distort.PixelTransform2_F32 |
getUndistToDist() |
boolean |
isConvex() |
boolean |
isOutputClockwise() |
void |
process(T gray,
boofcv.struct.image.GrayU8 binary)
Examines the undistorted gray scale input image for squares.
|
void |
resetRuntimeProfiling() |
void |
setContourEdgeThreshold(double contourEdgeThreshold) |
void |
setConvex(boolean convex) |
void |
setHelper(PolygonHelper helper) |
void |
setLensDistortion(int width,
int height,
boofcv.struct.distort.PixelTransform2_F32 distToUndist,
boofcv.struct.distort.PixelTransform2_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 |
setOutputClockwise(boolean outputClockwise) |
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.PixelTransform2_F32 distToUndist
protected boofcv.struct.distort.PixelTransform2_F32 undistToDist
public DetectPolygonFromContour(PointsToPolyline contourToPolyline, boofcv.struct.ConfigLength minimumContour, boolean outputClockwise, boolean touchBorder, double contourEdgeThreshold, double tangentEdgeIntensity, boofcv.abst.filter.binary.BinaryContourFinder contourFinder, java.lang.Class<T> inputType)
contourToPolyline - Fits a crude polygon to the shape's binary contourminimumContour - Minimum allowed length of a contour. Copy stored internally. Try 50 pixels.outputClockwise - If true then the order of the output polygons will be in clockwise ordertouchBorder - if true then shapes which touch the image border are allowedcontourEdgeThreshold - Polygons with an edge intensity less than this are discarded.inputType - Type of input image it's processingprotected DetectPolygonFromContour()
public void setLensDistortion(int width,
int height,
boofcv.struct.distort.PixelTransform2_F32 distToUndist,
boofcv.struct.distort.PixelTransform2_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.
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 resetRuntimeProfiling()
public void clearLensDistortion()
public void process(T gray, boofcv.struct.image.GrayU8 binary)
gray - Input imagepublic static void flip(int[] a,
int N)
public java.util.List<georegression.struct.point.Point2D_I32> getContour(DetectPolygonFromContour.Info info)
info - Which shapeprotected 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 boolean isOutputClockwise()
public java.util.List<boofcv.alg.filter.binary.ContourPacked> getAllContours()
public java.lang.Class<T> getInputType()
public void setNumberOfSides(int min,
int max)
public int getMinimumSides()
public int getMaximumSides()
public void setOutputClockwise(boolean outputClockwise)
public void setVerbose(boolean verbose)
public double getContourEdgeThreshold()
public void setContourEdgeThreshold(double contourEdgeThreshold)
public boofcv.struct.distort.PixelTransform2_F32 getDistToUndist()
public boofcv.struct.distort.PixelTransform2_F32 getUndistToDist()
public org.ddogleg.struct.FastQueue<DetectPolygonFromContour.Info> getFound()
public boofcv.abst.filter.binary.BinaryContourFinder getContourFinder()
public double getMilliContour()
public double getMilliShapes()