public class RefinePolygonLineToImage<T extends boofcv.struct.image.ImageGray> extends java.lang.Object implements RefineBinaryPolygon<T>
Improves the fits of a polygon's which is darker or lighter than the background. Polygon's edges are assumed to be perfectly straight lines. The edges are processed individually and fit to a line using weighted regression. Both black squares with white backgrounds and white shapes with black backgrounds can be found. The edges are selected to maximize the difference between light and dark regions.
For example, assume an image axis aligned rectangle has a lower extent of 1,2 and a upper extent of 12,15, is entirely filled, excluding the upper extent pixels (as is typical). Then the found lower and upper extends of the found polygon will also be 1,2 and 12,15.
If a line lies entirely along the image border it is not modified. If part of it lies along the image then only points not near the border are used to optimize its location.
For input polygons which are in undistorted coordinates by with a distorted image call getSnapToEdge()
and invoke BaseIntegralEdge.setTransform(PixelTransform2_F32).
| Constructor and Description |
|---|
RefinePolygonLineToImage(double cornerOffset,
int lineSamples,
int sampleRadius,
int maxIterations,
double convergeTolPixels,
double maxCornerChangePixel,
java.lang.Class<T> imageType)
Constructor which provides full access to all parameters.
|
RefinePolygonLineToImage(int numSides,
java.lang.Class<T> imageType)
Simplified constructor which uses reasonable default values for most variables
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearLensDistortion()
Clears the previously set lens distortion
|
SnapToLineEdge<T> |
getSnapToEdge() |
protected boolean |
optimize(georegression.struct.point.Point2D_F64 a,
georegression.struct.point.Point2D_F64 b,
georegression.struct.line.LineGeneral2D_F64 found)
Fits a line defined by the two points.
|
protected boolean |
optimize(georegression.struct.shapes.Polygon2D_F64 seed,
georegression.struct.shapes.Polygon2D_F64 current)
Refines the initial line estimates using EM.
|
boolean |
refine(georegression.struct.shapes.Polygon2D_F64 input,
java.util.List<georegression.struct.point.Point2D_I32> contour,
org.ddogleg.struct.GrowQueue_I32 splits,
georegression.struct.shapes.Polygon2D_F64 output)
Refines the fit a polygon by snapping it to the edges.
|
void |
setImage(T image)
Sets the image which is going to be processed.
|
void |
setLensDistortion(int width,
int height,
boofcv.struct.distort.PixelTransform2_F32 distToUndist,
boofcv.struct.distort.PixelTransform2_F32 undistToDist)
Specifies lens distortion
|
void |
setTransform(boofcv.struct.distort.PixelTransform2_F32 undistToDist)
Used to specify a transform that is applied to pixel coordinates to bring them back into original input
image coordinates.
|
protected T extends boofcv.struct.image.ImageGray image
public RefinePolygonLineToImage(double cornerOffset,
int lineSamples,
int sampleRadius,
int maxIterations,
double convergeTolPixels,
double maxCornerChangePixel,
java.lang.Class<T> imageType)
public RefinePolygonLineToImage(int numSides,
java.lang.Class<T> imageType)
numSides - Number of sides on the polygonimageType - Type of input image it processespublic void setImage(T image)
BaseIntegralEdge.setTransform(boofcv.struct.distort.PixelTransform2_F32) should be called before this.setImage in interface RefineBinaryPolygon<T extends boofcv.struct.image.ImageGray>public void setLensDistortion(int width,
int height,
boofcv.struct.distort.PixelTransform2_F32 distToUndist,
boofcv.struct.distort.PixelTransform2_F32 undistToDist)
RefineBinaryPolygonsetLensDistortion in interface RefineBinaryPolygon<T extends boofcv.struct.image.ImageGray>public void clearLensDistortion()
RefineBinaryPolygonclearLensDistortion in interface RefineBinaryPolygon<T extends boofcv.struct.image.ImageGray>public boolean refine(georegression.struct.shapes.Polygon2D_F64 input,
java.util.List<georegression.struct.point.Point2D_I32> contour,
org.ddogleg.struct.GrowQueue_I32 splits,
georegression.struct.shapes.Polygon2D_F64 output)
refine in interface RefineBinaryPolygon<T extends boofcv.struct.image.ImageGray>input - (input) Initial estimate for the polygon. CW or CCW ordering doesn't matter.output - (output) the fitted polygoncontour - List of pixels in the contoursplits - Indexes in the contour where the initial polygon was foundprotected boolean optimize(georegression.struct.shapes.Polygon2D_F64 seed,
georegression.struct.shapes.Polygon2D_F64 current)
protected boolean optimize(georegression.struct.point.Point2D_F64 a,
georegression.struct.point.Point2D_F64 b,
georegression.struct.line.LineGeneral2D_F64 found)
a - Corner point in image coordinates.b - Corner point in image coordinates.found - (output) Line in image coordinatespublic void setTransform(boofcv.struct.distort.PixelTransform2_F32 undistToDist)
undistToDist - Pixel transformation from undistorted pixels into the actual distorted input image..public SnapToLineEdge<T> getSnapToEdge()