Class DetectPolygonBinaryGrayRefine<T extends ImageGray<T>>


  • public class DetectPolygonBinaryGrayRefine<T extends ImageGray<T>>
    extends java.lang.Object
    Detects polygons using contour of blobs in a binary image. The contours can then have their edges refined as a whole or on an individual basis. Lens distortion can be specified. Lens distortion is handled in a sparse way along the contour of shapes.
    • Constructor Detail

      • DetectPolygonBinaryGrayRefine

        public DetectPolygonBinaryGrayRefine​(DetectPolygonFromContour<T> detector,
                                             RefinePolygonToContour refineContour,
                                             RefinePolygonToGray<T> refineGray,
                                             double minimumRefineEdgeIntensity,
                                             boolean adjustForThresholdBias)
        Configures the polygon detector
        Parameters:
        detector - Fits a polygon to a contour
        refineContour - Refines the polygon produce a better fit against the contour
        refineGray - Refine the edges to the input gray scale image
        minimumRefineEdgeIntensity - Threshold for pruning shapes. Must have this edge intensity. Try 6
        adjustForThresholdBias - Should it adjust contour polygons for the bias caused by thresholding?
    • Method Detail

      • setHelper

        public void setHelper​(PolygonHelper helper)
        Specify a helper used to inject specialized code into the polygon detector
      • setVerbose

        public void setVerbose​(boolean verbose)
        Turn on and off verbose output to standard out
      • setLensDistortion

        public void setLensDistortion​(int width,
                                      int height,
                                      @Nullable
                                      PixelTransform<Point2D_F32> distToUndist,
                                      @Nullable
                                      PixelTransform<Point2D_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.

        Parameters:
        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.
      • clearLensDistortion

        public void clearLensDistortion()
        Discard previously set lens distortion models
      • resetRuntimeProfiling

        public void resetRuntimeProfiling()
      • process

        public void process​(T gray,
                            GrayU8 binary)
        Detects polygons inside the grayscale image and its thresholded version
        Parameters:
        gray - Gray scale image
        binary - Binary version of grayscale image
      • refine

        public boolean refine​(DetectPolygonFromContour.Info info)
        Refines the fit to the specified polygon. Only info.polygon is modified
        Parameters:
        info - The polygon and related info
        Returns:
        true if successful or false if not
      • refineAll

        public void refineAll()
        Refines all the detected polygons and places them into the provided list. Polygons which fail the refinement step are not added.
      • getPolygons

        public java.util.List<Polygon2D_F64> getPolygons​(@Nullable
                                                         java.util.List<Polygon2D_F64> storage,
                                                         @Nullable
                                                         java.util.List<DetectPolygonFromContour.Info> storageInfo)
        Returns a list of all polygons with an edge threshold above the minimum
        Parameters:
        storageInfo - Optional storage for info associated with polygons. Pruning is done so the info list and the returned polygon list are not in synch with each other
      • getInputType

        public java.lang.Class<T> getInputType()
      • getMinimumSides

        public int getMinimumSides()
      • getMaximumSides

        public int getMaximumSides()
      • isOutputClockwise

        public boolean isOutputClockwise()
      • getAllContours

        public java.util.List<ContourPacked> getAllContours()
      • getMilliAdjustBias

        public double getMilliAdjustBias()