F_VN_MeasureAngleBetweenEdgesExp
Measure the angle between 2 edges.
Can use available TwinCAT Job Tasks for executing parallel code regions.
Can return partial results when canceled by Watchdog.
Syntax
Definition:
FUNCTION F_VN_MeasureAngleBetweenEdgesExp : 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;
fSearchLineDist : REAL;
nMaxThickness : UDINT;
bInvertSearchDirection : BOOL;
nSubpixelsIterations : UDINT;
bAngleInDegrees : BOOL;
fApproxPrecision : REAL;
eAlgorithm : ETcVnEdgeDetectionAlgorithm;
ipEdgePoints1 : Reference To ITcVnContainer;
ipEdgePoints2 : Reference To ITcVnContainer;
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
Source image (1 channel) | |
eEdgeDirection |
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 window, i.e. the number of search lines (3, 5, 7, ...), centered around the line specified by aInnerPoint and aOuterPoint1, aOuterPoint2 |
fSearchLineDist |
REAL |
Distance between the search lines in pixels (> 0) |
nMaxThickness |
UDINT |
Specification of the maximum thickness of the edge to search for, which means fMinStrength must be reached within nMaxThickness pixels |
bInvertSearchDirection |
BOOL |
If true, the search starts from each aOuterPoint in direction of aInnerPoint |
nSubpixelsIterations |
UDINT |
Specifies the number of subpixels (for INTERPOLATION, 10 - 20 usually is sufficient) or maximum number of iterations for optimizing the parameters (for APPROX_ERF and APPROX_GAUSSIAN, 50 - 100 usually is sufficient) |
bAngleInDegrees |
BOOL |
fAngle is in degrees, if true |
fApproxPrecision |
REAL |
Specifies the approximation precision for APPROX_ERF and APPROX_GAUSSIAN (0.001 usually is sufficient, unused for INTERPOLATION) |
eAlgorithm |
Selection of the edge detection algorithm | |
ipEdgePoints1 |
Reference To ITcVnContainer |
Returns the detected edge points between aInnerPoint and aOuterPoint1 (ContainerType_Vector_TcVnPoint2_REAL) |
ipEdgePoints2 |
Reference To ITcVnContainer |
Returns the detected edge points between aInnerPoint and aOuterPoint2 (ContainerType_Vector_TcVnPoint2_REAL) |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
In/Outputs
Name |
Type |
Description |
---|---|---|
fAngle |
REAL |
Returns the angle between the detected edges (radians or degrees, depending on bAngleInDegrees) |
aInnerPoint |
Position inside the angle to measure, from which to start the edge search process (in the direction of aOuterPoint1 and aOuterPoint2) | |
aOuterPoint1 |
Position where the search process for edge 1 ends | |
aOuterPoint2 |
Position where the search process for edge 2 ends |
Weiterführende Informationen
Die Funktion F_VN_MeasureAngleBetweenEdgesExp
ist die Expert-Variante von F_VN_MeasureAngleBetweenEdges.
Parameter
Eingangsbild
Das Eingangsbild ipSrcImage
muss ein 1-kanaliges Grauwertbild sein.
Winkel (Rückgabewert)
Der Parameter fAngle
gibt den Winkel zwischen den lokalisierten Kanten zurück.
Abhängig vom Parameter bAngleInDegrees
ist der Winkel fAngle
in Radiant (FALSE
) oder in Grad (TRUE
) angegeben.
Parameter zur Kantenlokalisierung
Die restlichen Parameter sind ausführlich im Kapitel Kantenlokalisierung erklärt.
Lokalisierte Punkte (Expert, Rückgabewert)
Die Container ipEdgePoints1
und ipEdgePoints2
geben die exakten Punkte zurück, die anhand jeder Suchlinie lokalisiert wurden. Falls nicht benötigt, kann anstatt eines Interface Pointers der Wert 0
übergeben werden
Parameter zur Kantenlokalisierung
Die restlichen Parameter sind ausführlich im Kapitel Kantenlokalisierung erklärt.
Anwendung
Das Vermessen eines Winkels mit Expert-Parametern sieht z. B. so aus:
hr := F_VN_MeasureAngleBetweenEdgesExp(
ipSrcImage := ipImageIn,
fAngle := fAngle
aInnerPoint := aInnerPoint,
aOuterPoint1 := aOuterPoint1
aOuterPoint2 := aOuterPoint2,
eEdgeDirection := TCVN_ED_LIGHT_TO_DARK,
fMinStrength := fMinStrength,
nSearchLines := nSearchLines,
fSearchLineDist := fSearchLineDist,
nMaxThickness := 7,
nSubpixelsIterations := 100,
bAngleInDegrees := TRUE,
fApproxPrecision := 0.0001,
eAlgorithm := TCVN_EDA_APPROX_ERF,
ipEdgePoints1 := ipEdgePoints1,
ipEdgePoints2 := ipEdgePoints2,
hrPrev := hr
);
Beispiele
Required License
TC3 Vision Metrology 2D
System Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT V3.1.4024.59 or later | PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU | Tc3_Vision |