F_VN_LocateCircularArc
Locate a circular arc, 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_LocateCircularArc : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
END_VAR
VAR_IN_OUT
stCircularArc : TcVnCircularArc;
aCenter : TcVnPoint2_REAL;
END_VAR
VAR_INPUT
fSearchRadius : REAL;
fArcDirectionRad : LREAL;
eEdgeDirection : ETcVnEdgeDirection;
fMinStrength : REAL;
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
Source image (1 channel) | |
fSearchRadius |
REAL |
Input search radius (starting from aCenter, should be greater than the actual circle radius but aCenter + fSearchRadius should be within the image borders) |
fArcDirectionRad |
LREAL |
Input search starting direction in radian. Valid range is [-pi, +pi], where right is 0 rad, top is -pi/2 rad and bottom +pi/2 rad. The circular arc should at least be valid in range fArcDirectionRad +- 0.4 rad. |
eEdgeDirection |
Specification of the edge direction to search for | |
fMinStrength |
REAL |
Specification of the minimum strength (intensity difference) of the edge to search for |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
In/Outputs
Name |
Type |
Description |
---|---|---|
stCircularArc |
Returns the circular arc parameters | |
aCenter |
Input estimated circle center (only used as a starting point to search for the circle contour, not used for the circle center estimation) |
Further information
The function F_VN_LocateCircularArc
localizes and measures a proportional circular arc. It is based on the edge localization and uses normal parameters. It returns the localized circular arc as a structure of the type TcVnCircularArc (center point, radius, angle range).
If full circles are to be measured instead of a circular arc, use the function F_VN_LocateEllipse instead.
Parameter
Input image
The input image ipSrcImage
must be a 1-channel grayscale image.
Circular arc (Return value)
The parameter stCircularArc
returns the localized circular arc as a structure of the type TcVnCircularArc.
Estimated center point
The estimated center point aCenter
of the circular arc must be specified in order to define the position of the search lines.
If the position of the center point of the circle is unknown, it may need to be determined beforehand by means of an object detection.
Search radius
The search radius fSearchRadius
defines the length of the search lines from the center point of the circle in pixels. The search radius should be defined somewhat larger than the actual radius of the circle so that the edge localization can be carried out unambiguously.
Search direction
The search direction fArcDirectionRad
specifies the circular direction in which the edge search should begin (starting from the center point of the circle). The value is to be specified in radians and has a value range of [-π, π]. Right corresponds to 0, top with –π/2 and bottom with π/2. Starting from fArcDirectionRad
, the circular arc must be present at least in the range of +- 0.4 in order to be detected. It is recommended to aim for the center of the circular arc.
Parameters for edge localization
The remaining parameters are explained in detail in the chapter Edge localization.
Expert parameters
The expert version F_VN_LocateCircularArcExp contains additional parameters.
Application
The localization and measurement of a proportional circular arc with a radius of 270px
and a search angle of 120°
looks like this, for example:
VAR
stArc : TcVnCircularArc;
aCenter : TcVnPoint2_REAL := [420, 310];
END_VAR
hr := F_VN_LocateCircularArc(
ipSrcImage := ipImageIn,
stCircularArc := stArc,
aCenterPoint := aCenter,
fSearchRadius := 270,
fArcDirectionRad := 2.1, // 2.1 rad equals 120°
eEdgeDirection := TCVN_ED_LIGHT_TO_DARK,
fMinStrength := 100,
hrPrev := hr
);
The properties of the localized circular arc can then be retrieved via the variables stArc.aCenter
, stArc.fRadius
, stArc.fStartAngle
and stArc.fEndAngle
. In addition, the circular arc can be visualized with the function F_VN_DrawCircularArc:
F_VN_DrawCircularArc(stArc, ipImageRes, aColorGreen, 5, hr);
Samples
Related functions
- LocateCircularArc for localizing proportional circular arcs
- LocateEdge for localizing linear edges
- LocateEdges for localizing several linear edges
- LocateEllipse for localizing complete ellipses
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 |