F_VN_MeasureMinEdgeDistanceExp
Measure the minimum distance within the specified search window between 2 edges. (expert function)
Can use available TwinCAT Job Tasks for executing parallel code regions.
Can return partial results when canceled by Watchdog.
Syntax
Definition:
FUNCTION F_VN_MeasureMinEdgeDistanceExp : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
END_VAR
VAR_IN_OUT
fMinDistance : REAL;
aStartPoint : TcVnPoint2_REAL;
aEndPoint : TcVnPoint2_REAL;
END_VAR
VAR_INPUT
eEdgeDirection : ETcVnEdgeDirection;
fMinStrength : REAL;
nSearchLines : UDINT;
fSearchLineDist : REAL;
nMaxThickness : UDINT;
bInvertSearchDirection : BOOL;
fSearchGap : REAL;
nSubpixelsIterations : UDINT;
fApproxPrecision : REAL;
eAlgorithm : ETcVnEdgeDetectionAlgorithm;
ipEdgePoints1 : Reference To ITcVnContainer;
ipEdgePoints2 : Reference To ITcVnContainer;
END_VAR
VAR_IN_OUT
aPoint1 : TcVnPoint2_REAL;
aPoint2 : TcVnPoint2_REAL;
END_VAR
VAR_INPUT
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
Source image (1 channel) | |
eEdgeDirection |
Specification of the edge direction from aStartPoint to aEndPoint 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 (1, 3, 5, 7, ...), centered around the line specified by aStartPoint and aEndPoint |
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 the center point between aStartPoint and aEndPoint in both directions |
fSearchGap |
REAL |
Optional width of a gap (>= 0, centered between aStartPoint and aEndPoint), that is neglected for searching edges (can reduce execution time). The 2 edges to search for must be on different sides of the gap. |
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) |
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 of the edge near aStartPoint (optional, set to 0 if not required; ContainerType_Vector_TcVnPoint2_REAL) |
ipEdgePoints2 |
Reference To ITcVnContainer |
Returns the detected edge points of the edge near aEndPoint (optional, set to 0 if not required; 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 |
---|---|---|
fMinDistance |
REAL |
Returns the minimum distance between the detected edges |
aStartPoint |
Position from which to start the search process (in the direction of aEndPoint) | |
aEndPoint |
Position where the search process ends | |
aPoint1 |
Returns the point on the edge near aStartPoint, for which the minimum distance is achieved | |
aPoint2 |
Returns the point on the edge near aEndPoint, for which the minimum distance is achieved |
Weiterführende Informationen
Die Funktion F_VN_MeasureMinEdgeDistanceExp
ist die Expert-Variante von F_VN_MeasureMinEdgeDistance. Sie enthält zusätzliche Parameter.
Parameter
Eingangsbild
Das Eingangsbild ipSrcImage
muss ein 1-kanaliges Grauwertbild sein.
Minimaler Abstand (Rückgabewert)
Der Parameter fMinDistance
gibt des minimalen Abstand der beiden lokalisierten Kanten zurück.
Lokalisierte Kantenpunkte (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.
Zusätzlich geben die Punkte aPoint1
und aPoint2
die Punkte zurück, die den minimalen Abstand zwischen den beiden Kanten haben.
Such-Lücke (Expert)
Bereich in der Mitte der definierten Suchlinie, der bei der Suche ausgelassen wird. Dadurch kann die Ausführungszeit verringert werden.
Parameter zur Kantenlokalisierung
Die restlichen Parameter sind ausführlich im Kapitel Kantenlokalisierung erklärt.
Anwendung
Die Vermessung der minimalen Kantendistanz mit Expert-Parametern sieht z. B. so aus:
hr := F_VN_MeasureEdgeDistance(
ipSrcImage := ipImageIn,
fMinDistance := fDistance
aStartPoint := aStartPoint,
aEndPoint := aEndPoint,
eEdgeDirection := TCVN_ED_LIGHT_TO_DARK,
fMinStrength := fMinStrength,
nSearchLines := nSearchLines,
fSearchLineDist := 3
nMaxThickness := 7,
bInvertSearchDirection := TRUE,
nSubpixelsIterations := 100,
fApproxPrecision := 0.0001,
eAlgorithm := TCVN_EDA_APPROX_ERF,
ipEdgePoints1 := ipEdge1,
ipEdgePoints2 := ipEdge2,
aPoint1 := aPoint1,
aPoint2 := aPoint2,
hrPrev := hr
);
Die lokalisierten Kantenpunkte können mit den Funktionen F_VN_DrawContours und F_VN_DrawPoint visualisiert werden:
hr := F_VN_DrawContours(ipEdgePoints1, -1, ipImageRes, aColorGreen, 5, hr);
hr := F_VN_DrawContours(ipEdgePoints2, -1, ipImageRes, aColorGreen, 5, hr);
F_VN_DrawPoint(aPoint1[0], aPoint1[1], ipImageRes, TCVN_DS_X, aColorGreen, hr);
F_VN_DrawPoint(aPoint2[0], aPoint2[1], ipImageRes, TCVN_DS_X, aColorGreen, hr);
Verwandte Funktionen
- ClosestPointsBF zur Berechnung der nächstgelegenen Punkte zweier Punktewolken
- MeasureAngleBetweenEdges zur Vermessung des Winkels zwischen zwei Kanten
- MeasureEdgeDistance zur Vermessung des durchschnittlichen Abstands zweier Kanten
- MeasureMinEdgeDistance zur Vermessung des minimalen Abstands zweier Kanten
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 |