Generate Template Image
Feature Description
This operator automatically generates a corresponding 2D grayscale image template based on the geometric shape type selected by the user (such as rectangle, circle, text, etc.) and specified dimension parameters. It utilizes the input camera intrinsics and the height range of the object from the camera to convert real-world millimeter (mm) dimensions into pixel dimensions in the image, thereby creating a dimensionally accurate template image.
Use Cases
When a template-based 2D vision algorithm is needed, but an actual captured template image is unavailable, this operator can be used to quickly generate a standard template. For example, if the standard geometric shape and dimensions of an object to be identified are known (such as a circular part with a 50mm diameter, or a rectangular packaging box 100mm long and 50mm wide), this operator can generate the corresponding template image for subsequent matching and recognition tasks.
Inputs and Outputs
Input Item |
Camera internal reference: The camera’s intrinsic matrix, used to convert real-world dimensions to pixel dimensions. This input must be provided. |
Output Item |
Template image: The generated single-channel grayscale template image. Zoom extents: The scaling ratio range (minimum value to 1) calculated based on the input height range. This output value can serve as a reference for the scaling parameter of subsequent 2D template matching operators to adapt to size changes caused by varying object distances. |
Parameter Descriptions
Height range
Parameter Description |
The possible height range of the target object from the camera. This range is used to calculate the pixel dimensions of the object at different distances and affects the output "Zoom extents". The first value is the minimum distance, and the second value is the maximum distance. |
Parameter Tuning Guide |
Estimate or measure the nearest and farthest possible distances of the workpiece based on the actual installation situation and fill in these two values. An accurate height range helps generate a more appropriately sized template and provides a useful scaling range parameter for subsequent matching. |
Parameter Range |
[0, 10000], Default values: 1500, 3500 respectively, Unit: mm |
Enable filling
Parameter Description |
Determines whether the generated shape is solid or just an outline. |
Parameter Tuning Guide |
Check this item if you want the template to be a solid shape; uncheck it if you only need the outline of the shape. |
Image edge fill ratio
Parameter Description |
The size ratio of the blank edge (background) added around the generated shape, calculated relative to the short side of the shape. |
Parameter Tuning Guide |
Increasing this value will make the generated template image larger, with more blank area around the shape. Appropriate blank edges help prevent the template image from being cropped during subsequent template matching if it rotates or slightly exceeds the boundaries. Usually, the default value is sufficient. If template matching is unstable because the template edge is too close to the image boundary, this value can be appropriately increased. |
Parameter Range |
[0, 1], Default value: 0.2 |
Line thickness
Parameter Description |
When "Enable filling" is off, this is the pixel thickness of the shape outline; if "Enable filling" is on, this parameter is usually ineffective (except for text templates). |
Parameter Tuning Guide |
Adjust only when generating outline templates. Increasing this value makes the outline thicker, decreasing it makes it thinner. Choose an appropriate value based on the clarity and thickness of the object edges in the actual image. |
Parameter Range |
[1, 100], Default value: 1 |
Shape Specific Parameters
Parameter Description |
Displayed according to the selected "Template type":
|
Parameter Tuning Guide |
Configure the corresponding geometric dimension parameters according to the selected template type. |
Parameter Range |
N/A |