F_VN_MeasureAngleBetweenEdges

F_VN_MeasureAngleBetweenEdges 1:

Measure the angle between 2 edges, using an interpolation method.
Can use available TwinCAT Job Tasks for executing parallel code regions.
Can return partial results when canceled by Watchdog.

Syntax

Definition:

FUNCTION F_VN_MeasureAngleBetweenEdges : HRESULT
VAR_INPUT
    ipSrcImage     : ITcVnImage;
END_VAR
VAR_IN_OUT
    fAngle         : REAL;
    aInnerPoint    : TcVnPoint2_REAL;
    aOuterPoint1   : TcVnPoint2_REAL;
    aOuterPoint2   : TcVnPoint2_REAL;
END_VAR
VAR_INPUT
    eEdgeDirection : ETcVnEdgeDirection;
    fMinStrength   : REAL;
    nSearchLines   : UDINT;
    hrPrev         : HRESULT;
END_VAR

F_VN_MeasureAngleBetweenEdges 2: Inputs

Name

Type

Description

ipSrcImage

ITcVnImage

Source image (1 channel)

eEdgeDirection

ETcVnEdgeDirection

Specification of the edge direction from aInnerPoint to aOuterPoint1 and aOuterPoint2 to search for

fMinStrength

REAL

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

nSearchLines

UDINT

Width of the search windows, i.e. the number of search lines (3, 5, 7, ...), centered around the lines specified by aInnerPoint and aOuterPoint1, aOuterPoint2

hrPrev

HRESULT

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

F_VN_MeasureAngleBetweenEdges 3: In/Outputs

Name

Type

Description

fAngle

REAL

Returns the angle between the detected edges (radians)

aInnerPoint

TcVnPoint2_REAL

Position inside the angle to measure, from which to start the edge search process (in the direction of aOuterPoint1 and aOuterPoint2)

aOuterPoint1

TcVnPoint2_REAL

Position where the search process for edge 1 ends

aOuterPoint2

TcVnPoint2_REAL

Position where the search process for edge 2 ends

F_VN_MeasureAngleBetweenEdges 4: Return value

HRESULT

Further information

The function F_VN_MeasureAngleBetweenEdges localizes two linear edges and measures the angle between them.

Parameter

Input image

The input image ipSrcImage must be a 1-channel grayscale image.

Angle (Return value)

The parameter fAngle returns the angle between the localized edges.

Depending on the parameter bAngleInDegrees, the angle fAngle is specified in radians (FALSE) or in degrees (TRUE).

Parameters for edge localization

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

Expert parameters

The expert version F_VN_MeasureAngleBetweenEdgesExp contains additional parameters.

Application

The measurement of an angle between two linear edges looks like this, for example:

hr := F_VN_MeasureAngleBetweenEdgesExp(
    ipSrcImage             :=   ipImageIn,
    fAngle                 :=   fAngle
    aInnerPoint            :=   aInnerPoint,
    aOuterPoint1           :=   aOuterPoint1
    aOuterPoint2           :=   aOuterPoint2,
    eEdgeDirection         :=   TCVN_ED_LIGHT_TO_DARK,
    fMinStrength           :=   fMinStrength,
    nSearchLines           :=   nSearchLines,
    hrPrev                 :=   hr
);

Samples

Required License

TC3 Vision Metrology 2D

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