Measurement
The group contains functions for the measurement of objects in images.
Functions
Edge localization
- LocateCircularArc for localizing proportional circular arcs
- LocateEdge for localizing linear edges
- LocateEdges for localizing several linear edges
- LocateEllipse for localizing complete ellipses
Geometrical features
- ClosestPointsBF for calculating the closest points in two point clouds
- MeasureAngleBetweenEdges for measuring the angle between two edges
- MeasureEdgeDistance for measuring the average distance between two edges
- MeasureMinEdgeDistance for measuring the minimum distance between two edges
Miscellaneous
- F_VN_AdjustSearchWindowOrientationToLinearEdge for aligning the search field to an edge
Parameters for edge localization
The borders of an image object often don't lie exactly on the border between two pixels. Instead, they run independently of pixel grids. Therefore edge localization with sub-pixel accuracy is necessary. This not only considers the transition between two pixels, but also determines the edge position within a pixel on the basis of the overall intensity gradient of an object border.
Notice | |
Don't process the image before measuring Don't process the image before calling the measurement function. Processing can lead to loss of information and lower accuracy accordingly. |
This basic functionality of edge localization is used by all measurement functions. The functions differ mainly by the geometric arrangement in which they perform the edge localization (e.g. F_VN_LocateEllipse for round objects) and the properties that you calculate from them (e.g. F_VN_MeasureAngleBetweenEdges for angle measurement).
Certain parameters must be defined for each function that uses edge localization. These include:
- Definition of the search area: where is the edge sought?
- Definition of edge contrast: What is detected as an edge?
- Definition of the measurement algorithm: How to determine the exact position of the edge.
These parameters are described below. In the case of expert parameters, standard values are specified in addition.
Search area
Parameter | Description |
---|---|
Position of the search lines | The position of the search lines is defined according to the feature to be localized. The position of search lines for a linear edge is defined as a single line with the start point The position of search lines for an ellipse is defined by a center point The position of search lines for angles is defined by an inner point The position of the search lines should always be set such that the search lines cut the edges to be localized orthogonally. A rectangular search area can be adjusted orthogonally to an edge with the function F_VN_AdjustSearchWindowOrientationToLinearEdge. |
Number of search lines
| This specifies how many search lines are to be used for the edge localization. The simplest edge localization has one search line on which the edge must be found. Depending on the geometric feature to be determined, multiple search lines are distributed locally so that several edge transitions are localized. This can be necessary in the following cases:
When localizing linear edges, the search lines are arranged symmetrically on both sides of the central search line, the central search line being included in |
Distance between the search lines
(Expert) Default: | The search lines distance defines the distance between neighboring search lines in pixels (> 0, default 1). This allows flexible balancing between accuracy and computing time. |
Inversion of the search direction
(Expert) Default: | The localization algorithm always searches for the edge from one end of the search line to the other. e.g. searching takes place from aStartPoint to aEndPoint. If it is necessary to invert this search direction due to the image properties (i.e. to start from the other end of the search lines), this parameter helps. |
Edge contrast
Parameter | Description |
---|---|
Edge direction
| The edge direction determines whether an edge transition from light to dark or from dark to light should be found. The following values are available for this:
|
Minimum strength
| The minimum strength defines the minimum difference in intensity required within an edge for it to be found. This makes it possible to control how much contrast an edge must have in order to be found. |
Maximum thickness
(Expert) Default: | The maximum thickness specifies the number of pixels within which This allows you to control whether only sharp edges or also very blurred edges are to be found. |
Algorithm
Parameter | Description |
---|---|
Algorithm
(Expert) Default: | This parameter defines the localization algorithm used. The available options are:
The A Gaussian function is well suited for lines, i.e. a dark-light-dark transition or vice versa. However, the brightness plateau may only be a few pixels wide, otherwise the erf function should be used. |
Subpixels / Iterations
(Expert) Default: 10 | The meaning of this parameter depends on the localization algorithm used. At the number of subpixels considered defines the fine granularity with which the search line evaluates the underlying pixel intensities. A value of 10, for example, specifies that 10 measured values are taken over a length of 1 pixel. Recommended: At the number of iterations is an abort criterion that defines the maximum number of iterations with which the edge model is to be approximated for the pixel intensities. More iterations increase the runtime; if this is too high the interpolation method should be used. Recommended: |
Approximation accuracy
(Expert) Default: | The approximation accuracy is a further abort criterion of the edge localization. It is only observed if the localization algorithm is The approximation of the edge or line is aborted if either the number of iterations of Recommended: |
Interpretation of the HRESULT
The HRESULT return values have the following meaning:
Code | Name | Description |
---|---|---|
16#000 | S_OK | Function was successfully executed and an edge was located on all search lines. |
16#001 | S_FALSE | Function was successfully executed, but edges were not located on each search line. |
16#256 | S_WATCHDOGTIMEOUT | Function was aborted by the watchdog. In this case, all measurement functions can return partial results. |
16#70C | NOTFOUND | Function was executed successfully, but no edge could be found on any search line. It is assumed that a measurement function is only called if it is ensured that the image contains an object with the parameterized edge properties. If none of the search lines are found, this indicates incorrect parameterization or an unsuitable call of the function. Therefore, an error code is output in this case. |
16#7xx | All error codes except NOTFOUND | Function was not executed successfully. See also: ADS Return Codes |
The following query, for example, can be used for the processing of the return value:
IF SUCCEEDED(hr) THEN
// Process results
IF hr <> S_OK THEN
// Emit warning that not all search lines were found
END_IF
ELSIF hr = Tc2_System.E_HRESULTAdsErr.NOTFOUND THEN
// Emit warning for wrong parametrization or missing piece
ELSE
// Error handling
END_IF
Reducing execution time
The execution time for a fixed search window varies slightly depending on the position of the component in the image. If the edge that is found is closer to the starting point, the execution time is shorter than for an edge further away.
A larger fluctuation can occur with the two approximation algorithms, since these require different iterations in order to approximate the model parameters using the surrounding pixel intensities.
In general, fewer iterations are required if the search lines of the search window hit the edge as orthogonally as possible. If the position and orientation of the objects in the image are subject to little or no fluctuation, the search window can be adjusted accordingly to achieve shorter execution times. In addition, the maximum time required can be reduced by reducing the maximum number of iterations, but this may lead to less accurate results.
In addition, the time can be limited with an external watchdog, which terminates the execution of the function if necessary and returns the existing partial results.
Samples
- F_VN_AdjustSearchWindowOrientationToLinearEdge
- F_VN_ClosestPointsBF
- F_VN_LocateCircularArc
- F_VN_LocateCircularArcExp
- F_VN_LocateEdge
- F_VN_LocateEdgeExp
- F_VN_LocateEdges
- F_VN_LocateEdgesExp
- F_VN_LocateEllipse
- F_VN_LocateEllipseExp
- F_VN_MeasureAngleBetweenEdges
- F_VN_MeasureAngleBetweenEdgesExp
- F_VN_MeasureEdgeDistance
- F_VN_MeasureEdgeDistanceExp
- F_VN_MeasureMinEdgeDistance
- F_VN_MeasureMinEdgeDistanceExp