Skip to content

2D Image Template Matching

Operator Function

Find the template image in the target image and output its center coordinates and bounding rectangle parameters.

Parameter Introduction

Input Parameters

ParameterRangeDefault ValueDescriptionIllustration
Input ImageIM number for image input
Template Image SourceMethod for inputting the template image, including:
IM number: IM number for image input
Template file path: File path for image input

Calculation Parameters

ParameterRangeDefault ValueDescriptionIllustration
Use Region Parameterstrue/falsefalseIf enabled, use the region as input; if disabled, use the input image as input
Region2D Window2D WindowSet the range of the search area
Edge Luminance ThresholdParameter for Canny edge detection. Higher values filter out more details.
Low Threshold0-25550Threshold for weak edges, affects edge retention.
High Threshold0-255100Threshold for strong edges, affects edge determination.
Matching Precision0-20.8Smaller values result in finer matching.
Matching SpeedSlow/Medium/FastMediumAlgorithm running speed. Faster speeds may reduce accuracy, including:
Slow: No feature pyramid
Medium: Pyramid level set to 2
Fast: Pyramid level set to 4
Scaling Down Ratio0.5-11.000Allowed scaling down ratio of target contour area relative to template contour.
Scaling Up Ratio1-1.51.000Allowed scaling up ratio of target contour area relative to template contour.
Negative Angle-180-00Counterclockwise rotation angle when training the template.
Positive Angle0-1800Clockwise rotation angle when training the template.
Score Filter0-10.900Difference between target contour shape and template contour shape. Smaller is better.
Search Quantity1-5005Number of target templates to find.

Result Display

ParameterRangeDefault ValueDescriptionIllustration
Center Pointtrue/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.
Featurestrue/falsefalseIf enabled, display the found target contour 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
point_arraypoint2d[]Found target center point information.
rect_arrayrect2d[]Found target rectangle information (center point, size, angle relative to the template image).

Exception Troubleshooting

No.Exception InformationCorresponding ParameterSolution
1File "{0}" does not exist or cannot be accessed.File pathCreate the file or change to a file with read permissions.
2File "{0}" cannot be opened successfully.File path1. Close programs using the file
2. Check if the disk is normal
3. Ensure the file format is correct
3Input image is empty.Check if the template image is empty.
4Reduce score.Reduce the score. The target score is too high, filtering out all results.
5Not found.Adjust precision and angle.
6Input value is {0t}, invalid region type.Region typeOnly window2d is supported.

Example Introduction

Engineering Design

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

  2. Select the 2D Template Creation tool to create a template file and output the template image to IM1.

  3. Select the 2D Image Template Matching tool.

Tool Usage

  1. Select input image IM0, set the template image source as Image Register, and select Image Register 1 (i.e., IM1).

  2. Set the parameters.

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

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

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

Local Image

AI-Vision, Making 3D Measurement Easier