F_VN_MergeRegions
Merge rectangles that overlap or whose edge-to-edge gap is within the specified distance.
Syntax
Definition:
FUNCTION F_VN_MergeRegions : HRESULT
VAR_INPUT
ipSrcContainer : ITcVnContainer;
ipDestContainer : Reference To ITcVnContainer;
nDistance : UDINT;
nOptions : ULINT;
hrPrev : HRESULT;
END_VARInputs
|
Name |
Type |
Description |
|---|---|---|
|
ipSrcContainer |
Source container containing rectangles to be merged (ContainerType_Vector_TcVnRectangle_DINT) | |
|
ipDestContainer |
Reference To ITcVnContainer |
Returns the resulting container, same type as ipSrcContainer |
|
nDistance |
UDINT |
Maximum edge-to-edge gap (in pixels) for two non-overlapping rectangles to be merged (overlapping rectangles are always merged) |
|
nOptions |
ULINT |
Specifies the method for merging regions. Valid values are defined in ETcVnMergeRegionsOptions. |
|
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_MergeRegions merges rectangles into a single region if they overlap or if the distance between their edges does not exceed a specified value.
Typically, this function is used for post-processing detection results in which objects have been detected multiple times in adjacent ROIs and the resulting regions overlap or are contiguous. One use case is the post-processing of the code regions detected by F_VN_DetectCodesNeuralNetwork in order to merge codes detected multiple times at the boundaries of adjacent ROIs into a single result region. The grouped regions can then be reused as ROIs and, in this example, passed to a code-reading function.
Parameter
List of rectangles
The list of rectangles to be merged is passed via ipSrcContainer in a container of type ContainerType_Vector_TcVnRectangle_DINT.
List of resulting regions
The aggregated regions are returned in ipDestContainer, which has the same type as ipSrcContainer.
Distance
The parameter nDistance is the maximum pixel distance between two rectangles for them to be merged. Overlapping rectangles are always merged. For non-overlapping rectangles, the following applies: The distance in the x-direction and the distance in the y-direction must each be less than or equal to nDistance. A distance of 0 means that two rectangles are touching each other and will therefore also be merged.
Options
The nOption parameter specifies the method used to merge the individual sections. The methods are defined in ETcVnMergeRegionsOptions:
TCVN_MRO_UPRIGHT_BOUNDING_RECT: Each aggregated region is represented by the smallest enclosing rectangle parallel to the axes.
Required License
TC3 Vision Base
System Requirements
Development environment | Target platform | PLC libraries to include |
|---|---|---|
TwinCAT V3.1.4024.59 or later | PC or CX (x64) with min. PL50, e.g. Intel 4-core Atom CPU | Tc3_Vision |