Leaper Vision Toolkit
中文 / English 2.x
Public Member Functions | Properties
ILContourDetector Interface Reference

This interface provide functionalities of sub-pixel contour detection. More...

Inheritance diagram for ILContourDetector:
ILObject LContourDetector

Public Member Functions

LPVErrorCode Detect (ILImage *img, ILRegion *region, ILContourResults **results)
 
enum LPVErrorCode DetectWithDir (ILImage *img, ILRotRectRegion *region, LPVPolarity contourPolarity, int tolerance, int threshold, ILContourResults **results)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Properties

int ConnectTolerance [get, set]
 The connect tolerance used in contour connection. For two contour candidates whose end points are nearby, we connect them into one result. By default, it's set to 1 which means no extra connection.
 
LPVExcludeBoundaryMode ExcludeBoundaryMode [get, set]
 The mode how to handle contours that intersect the region boundary, only LPVEBModeEntire and LPVEBModeNone is supported.
 
int FilterShort [get, set]
 The relative length threshold in percentage based on the longest contour in the candidates, used to filter a short contour. Worked together with FilterWeak, the short-and-weak is filtered.
 
int FilterWeak [get, set]
 The relative magnitude threshold in percentage based on the strongest contour in the candidates, used to filter a weak contour. Worked together with FilterShort, the short-and-weak is filtered.
 
int KSize [get, set]
 The kernel size used in edge filtering, should be an odd number, say, 3, 5, 7, etc. By default, it's 3. For the blurring image, you may use a bigger kernel size.
 
int MaxCount [get, set]
 The maximum of contours to find. If there are more than the setting counts of contours, sort the candidates then pick the tops. More...
 
BOOL OnlyClosed [get, set]
 Whether to report only closed contour results. By default, it's off.
 
int RejectShort [get, set]
 The absolute length threshold used to reject a short contour. Worked together with RejectWeak, the very short-or-weak is rejected.
 
int RejectWeak [get, set]
 The absolute magnitude threshold used to reject a weak contour. Worked together with RejectShort, the very short-or-weak is rejected.
 
LPVContourFeatures SortBy [get, set]
 The method used to sort all contour candidates, the top ones are reported as final results. More...
 
BOOL SortByDescending [get, set]
 Works together with SortBy. True to sort all contour candidates descending(from large value to small), false for sorting in ascending order. More...
 

Detailed Description

This interface provide functionalities of sub-pixel contour detection.

Contour detector is designed to locate a single or multiple contours in given image.
For the outstanding edge pixels in the image, the algorithm connect the nearby ones into contours based on their direction consistence. We may then reject/filter short and weak contours, and also filter them by polarity along the region's direction.
The algorithm is real-time and has accuracy of sub-pixel.

To use this interface, you should create a LContourDetector object.

Example Code

Member Function Documentation

◆ Detect()

LPVErrorCode Detect ( ILImage img,
ILRegion region,
ILContourResults **  results 
)

Detect contours using the contour detector.

Parameters
[in]img The input image.
[in]regionThe input region.
[out]resultsReturn the contour results.
Return values
errorReturn error code if anything is wrong.

◆ DetectWithDir()

enum LPVErrorCode DetectWithDir ( ILImage img,
ILRotRectRegion region,
LPVPolarity  contourPolarity,
int  tolerance,
int  threshold,
ILContourResults **  results 
)

Detect contours and filter by their trend and edge transition direction.
For each pixel on the contour, its edge transition direction is compared with the region's direction. The inconsistent pixels are filtered then excluded from the contour result. If there's too much excluded pixels on the contour than the setting threshold, the entire contour is filtered.

Parameters
[in]img The input image.
[in]regionThe input region, it should be a rotated rectangle region with its direction well-defined.
[in]contourPolarityThe edge polarity according to region's direction.
[in]toleranceThe direction difference tolerance in degrees.
[in]thresholdThe filtered pixels' percentage in the total count
[out]resultsReturn the contour results.
Return values
errorReturn error code if anything is wrong.

Property Documentation

◆ MaxCount

int MaxCount
getset

The maximum of contours to find. If there are more than the setting counts of contours, sort the candidates then pick the tops.

See also
SortBy

◆ SortBy

LPVContourFeatures SortBy
getset

The method used to sort all contour candidates, the top ones are reported as final results.

See also
MaxCount, SortByDescending

◆ SortByDescending

BOOL SortByDescending
getset

Works together with SortBy. True to sort all contour candidates descending(from large value to small), false for sorting in ascending order.

See also
SortBy