F_VN_AdjustSearchWindowOrientationToLinearEdge

F_VN_AdjustSearchWindowOrientationToLinearEdge 1:

Adjust the search window to be orthogonal to a linear edge. Might be helpful before calling edge localization and distance measurement functions that rely on the search window.
Can use available TwinCAT Job Tasks for executing parallel code regions.

Syntax

Definition:

FUNCTION F_VN_AdjustSearchWindowOrientationToLinearEdge : HRESULT
VAR_INPUT
    ipSrcImage     : ITcVnImage;
END_VAR
VAR_IN_OUT
    aStartPoint    : TcVnPoint2_REAL;
    aEndPoint      : TcVnPoint2_REAL;
END_VAR
VAR_INPUT
    eEdgeDirection : ETcVnEdgeDirection;
    fMinStrength   : REAL;
    nMaxThickness  : UDINT;
    nSearchLines   : UDINT;
    hrPrev         : HRESULT;
END_VAR

F_VN_AdjustSearchWindowOrientationToLinearEdge 2: Inputs

Name

Type

Description

ipSrcImage

ITcVnImage

Source image

eEdgeDirection

ETcVnEdgeDirection

Specification of the edge direction to search for

fMinStrength

REAL

Specification of the minimum strength (intensity difference) of the edge to search for

nMaxThickness

UDINT

Specification of the maximum thickness of the edge to search for, which means fMinStrength must be reached within nMaxThickness pixels

nSearchLines

UDINT

Width of the search window, i.e. the number of search lines (3, 5, 7, ...), centered around the line specified by aStartPoint and aEndPoint

hrPrev

HRESULT

HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.)

F_VN_AdjustSearchWindowOrientationToLinearEdge 3: In/Outputs

Name

Type

Description

aStartPoint

TcVnPoint2_REAL

Position from which to start the search process (in the direction of aEndPoint), which is not changed

aEndPoint

TcVnPoint2_REAL

Position where the search process ends, which is adjusted by this function

F_VN_AdjustSearchWindowOrientationToLinearEdge 4: Return value

HRESULT

Further information

The F_VN_AdjustSearchWindowOrientationToLinearEdge function rotates the search field for measurement functions in such a way that it lies orthogonal to a linear edge.

Parameter

Input image

The ipSrcImage input image must contain an edge in accordance with the parameters for edge detection.

Search window (Return value)

The search window to be adjusted is transferred as a reference so that it can be changed by the function. The search window consists of the central search line, which is indicated by a aStartPoint start point and aEndPoint end point, as well as the number of nSearchLines search lines.

Following the function call, aStartPoint and aEndPoint contain the adjusted central search line. This is now orthogonal to the linear edge on the ipSrcImage input image.

Parameters for edge localization

The remaining parameters are explained in detail in the chapter Edge localization.

Application

The adaptation of the search window to an edge looks like this, for example:

hr := F_VN_(
    ipSrcImage      := ipImageIn,
    aStartPoint     := aStartPoint,
    aEndPoint       := aEndPoint,
    eEdgeDirection  := eDirection,
    fMinStrength    := fMinStrength,
    nMaxThickness   := nMaxThickness,
    nSearchLines    := nSearchLines,
    hrPrev          := hr);

Required License

TC3 Vision Metrology 2D

System Requirements