Template Matching

You are viewing an old version of the documentation. You can switch to the documentation of the latest version by clicking the top-right corner of the page.

Function

This Step matches the objects in the input image with the 2D template to calculate the 2D poses of the objects.

Usage Scenario

This Step is used to locate the target objects in the image, in order to calculate the poses or the 2D transformation for image position and orientation correction in subsequent Steps.

Input and Output

template matching input and output

Parameter Description

The workflow of adjusting the parameters of this Step is as follows:

template matching step workflow
Gradient Magnitude Lower Threshold

Default value: 60

Instructions: Object features must be extracted before matching. Pixels with gradient magnitudes greater than this threshold are regarded as feature pixels for matching. The following figure shows the extracted feature pixels of the same object when Gradient Magnitude Lower Threshold is set to 10 (left) and 60 (right).

When it is set to 10, the feature pixel extraction is not quite accurate, and some feature pixels fall on the background. When it is set to 60, the feature pixel extraction is more accurate. Therefore, an appropriate increase in the threshold is conducive to raising the accuracy of feature pixel extraction.

template matching gradient magnitude lower threshold
Template Features Already Extracted

Default value: Unchecked.

Instructions: When this Step is run for the first time, this option is unchecked by default. Therefore, the feature pixels of the imported template image (from Template Image File Path) are extracted and saved to Template Feature File Path. Then, the feature pixels of the input image are extracted, and matching is performed. When this Step is run again, this option is automatically checked, and matching is performed using the saved feature pixels of the template image. If you need to extract the feature pixels of the template image, such as when you changed the template image, please uncheck this option and run this Step.

Template Settings (displayed when Template Features Already Extracted is unchecked)

Template Feature File Path

Instructions: Select the directory for saving the template feature files.

Template Image File Path

Instructions: Select the template image output by Make Template.

Template Mask File Path

Instructions: Select the template mask output by Make Template.

Starting Angle

Default value: –180.0

Instructions: Starting Angle and End Angle specify the rotation range of the template in the input image during matching.

End Angle

Default value: 180.0

Instructions: Starting Angle and End Angle specify the rotation range of the template in the input image during matching.

Angle Step

Default value: 1.0

Instructions: Angle Step determines the rotation increment of matching attempts.

Starting Scale

Default value: 0.80

Instructions: Starting Scale and End Scale specify the scaling range of the template in the input image during matching.

End Scale

Default value: 1.20

Instructions: Starting Scale and End Scale specify the scaling range of the template in the input image during matching.

Scale Step

Default value: 0.20

Instructions: Scale Step determines the scaling increment of matching attempts.

Match Settings (displayed when Template Features Already Extracted is checked)

Matching Score Lower Threshold

Default value: 50.0

Instructions: Matching results with scores lower than this threshold are discarded, and the remaining results will be output after being filtered in the refinement process of this Step.

  • If some objects are blocked by others, this threshold should be lowered accordingly.

  • If this threshold is set too high, all results might be discarded and none will be output.

Upper Limit for Number of Matches

Default value: 3

Instructions: If the actual number of matching results is greater than this value, the results at the end of the list are discarded.

  • When Matching Score Lower Threshold is kept constant, the higher the value of Upper Limit for Number of Matches, the more matching results may be output.

  • When Matching Score Lower Threshold is set to 25, and Upper Limit for Number of Matches is set to 1 or 4, the matching results are shown in the following figures. The left figure shows the matching result when Upper Limit for Number of Matches is set to 1, while the right figure shows the matching result when Upper Limit for Number of Matches is set to 4.

template matching matching settings 1
  • When Upper Limit for Number of Matches is kept constant, the higher the value of Matching Score Lower Threshold, the fewer matching results may be output. When Upper Limit for Number of Matches is set to 4, and Matching Score Lower Threshold is set to 25 or 50, the matching results are shown in the following figures. The left figure shows the matching result when Matching Score Lower Threshold is set to 25, while the right figure shows the matching result when Matching Score Lower Threshold is set to 50.

template matching matching settings 2

In the figure above, because only 3 matching results have scores higher than the set value of Matching Score Lower Threshold, so only 3 results at most can be output.

Overlap Ratio Upper Threshold

Default value: 0.40

Instructions: If two matching results overlap and the overlap ratio exceeds this value, the result with the higher matching score is kept, and the other one is discarded.

Refinement Settings (displayed when Template Features Already Extracted is checked)

Search Radius

Default value: 10.0

Instructions: The search radius is used to find the correspondences in pose refinement. When the matching results are not very good, please increase this value accordingly.

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.