FB_VN_GeneralizedHoughBallard

This FB provides the Generalized Hough Ballard functionality. First, set the parameters via the corresponding methods (optional, defaults are used otherwise). Then, set the template (required). Afterwards, the Detect method can be executed.

Do not call the main FB directly. Only use the available methods.

FB_VN_GeneralizedHoughBallard 1: Methods

Name

Description

Detect

Detect the template in an image (SetTemplate must have been called before).

SetCannyThreshold

Sets the canny edge detection thresholds.

SetInvAccuRatio

Sets the inverted ratio of the accumulator size in relation to the source image's size (e.g. a value of 2 means that the size is halved in both directions.)

SetLevels

Sets the number of R-table levels.

SetMinDist

Sets the minimum distance between the centers of different objects.

SetTemplate

Sets the template image to search for in the Detect method.

SetVotesThreshold

Sets the accumulator threshold, i.e. the number of votes required to detect a match (too small values lead to false detections).

Further information

The function block FB_VN_GeneralizedHoughBallard finds an arbitrary shape in a grayscale image using the generalized Hough transformation. The center positions of the recognized template shapes are determined, whereby different scaling and rotation of the template are not taken into account.

Parameter

Input images

The template and input image must be a 1-channel image with element type USINT (8-bit). First, the template image must be passed using the SetTemplate method. After that, the execution can be done by calling the Detect method, where the input image is then passed.

Parameters for detection

The following parameters can be set by method call. Otherwise, these default values are used. Since the parameters are already used for internal calculations when the template image is passed, the values must always be set first.

CannyThresholdLow = 50

CannyThresholdHigh = 100

InvAccuRatio = 1.0

Levels = 360

MinDist = 1.0

VotesThreshold = 100

List of center points found (return value)

All center point positions found in the image are returned after calling the Detect method in the container ipPositions.

Application

The execution consists of 3 steps. First the parameters are set and then the template image is passed. After that it is sufficient to call only the Detect method with the images on which to search for the template. Only if parameters or the template are to be changed, the corresponding steps have to be executed again.

// Set parameters first
hr := fbGenHoughBallard.SetCannyThreshold(50,150);
IF SUCCEEDED(hr) THEN hr := fbGenHoughBallard.SetInvAccuRatio(2); END_IF
IF SUCCEEDED(hr) THEN hr := fbGenHoughBallard.SetLevels(180); END_IF
IF SUCCEEDED(hr) THEN hr := fbGenHoughBallard.SetMinDist(20); END_IF
IF SUCCEEDED(hr) THEN hr := fbGenHoughBallard.SetVotesThreshold(80); END_IF

// Check if successful and set template image
IF SUCCEEDED(hr) THEN hr := fbGenHoughBallard.SetTemplate(ipTemplateImage); END_IF

// Check if successful and call detection
IF SUCCEEDED(hr) THEN hr := fbGenHoughBallard.Detect(ipSrcImage,ipPositions); END_IF

Required License

TC3 Vision Matching

System Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT V3.1.4024.54 or later

PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU

Tc3_Vision