Skip to content

2D Contour Template Matching

Operator Function

Find target contours in the ROI of the input image.

Parameter Introduction

Input Parameters

ParameterRangeDefault ValueDescriptionIllustration
Input Image0-80IM number for image input

Calculation Parameters

ParameterRangeDefault ValueDescriptionIllustration
Use Region Parameterstrue/falsefalseIf enabled, use region as input; if disabled, use input image as input
Region2D Window2D WindowSet the range of the search area
PolarityBrighter than background/Darker than backgroundDarker than backgroundBrighter than background: Find high brightness blobs
Darker than background: Find low brightness blobs
Both: Find both high and low brightness blobs
Binarization Threshold1-25590.000Threshold for image binarization
Search Quantity1-50010Number of blobs to find
Minimum Blob Area0.000-1000000.0000.000Minimum blob area to find
Maximum Blob Area1.000-1000000.000100000.000Maximum blob area to find
Hole Fillingtrue/falsefalseMinimum hole area: Fill holes smaller than this value

Result Display

ParameterRangeDefault ValueDescriptionIllustration
Contourtrue/falsefalseIf enabled, display the found target contour on the IM image
Center of Gravitytrue/falsefalseIf enabled, display the found target center point on the IM image
Bounding Rectangletrue/falsefalseIf enabled, display the found target bounding rectangle on the IM image
Matching Informationtrue/falsefalseIf enabled, display the found target information on the IM image

Output Parameters

NameTypeRangeDescription
Resultbooltrue/falsetrue for success
false for failure
Warningbooltrue/falsetrue indicates a warning
false indicates no warning
MessagestringOutput success, error, or warning messages. Empty if no error or warning.
TimefloatOperator execution time, unit: ms
area_arrayfloat[]Found target area
point_arraypoint2d[]Found target center point information
oriented_boxesrect2d[]Found target rectangle information (center point, size, angle relative to the template image)

Exception Troubleshooting

No.Exception InformationCorresponding ParameterSolution
1Input image is emptyCheck if the content in the input path is correct
2Template not foundEnsure there are contours with correct polarity in the template image
3Input value is {0t}, invalid region typeRegion typeOnly window2d supported
4Not found1. Lower the score 2. Adjust the area range

Example Introduction

Engineering Design

  1. Select the Load Image tool to load the template image to IM1.

  2. Select the Load Image tool to load the required 2D matching image to IM0.

  3. Select the 2D Contour Template Matching tool.

Tool Usage

  1. Select the input image and template image for the operation. The image numbers must match the IM numbers where the images are located in the project.

  2. Move the window to the position to be measured, enclosing the image to be tested.

::: Warning Tips 1. Use the ROI controller on the image window to drag or scale the window; 2. Directly modify the window's start or end point coordinates in the calculation parameters to adjust the window position and size; :::

  1. Set the parameters.

  2. Check the content you want to display in the result display section.

  3. Click Test to check if the image window and parameters meet expectations.

  4. If there are no issues, click Save. Run the operator in the run list, and then view the running results in the corresponding IM.

Result_img

AI-Vision, Making 3D Measurement Easier