🔷Generate Template Image

Functional Description

This operator automatically generates a corresponding 2D grayscale image template based on user-selected geometric shape types (such as rectangles, circles, text, etc.) and specified dimension parameters. It utilizes input camera intrinsics and the height range of objects from the camera to convert real-world millimeter (mm) dimensions to pixel dimensions in images, thus creating template images with accurate dimensions.

Usage Scenarios

When using 2D vision algorithms based on template matching but lacking actual captured template images, this operator can be used to quickly generate a standard template. For example, when knowing the standard geometric shape and dimensions of the object to be identified (such as a circular part with 50mm diameter, or a rectangular package box 100mm long and 50mm wide), this operator can be used to generate corresponding template images for subsequent matching and identification tasks.

Input Output

Input

Camera Intrinsics: Camera intrinsic matrix used to convert real-world dimensions to pixel dimensions. Must provide this input.

Output

Template Image: Generated single-channel grayscale template image.

Scale Range: Scale ratio range (minimum value to 1) calculated based on input height range. This output value can serve as scale parameter reference for subsequent 2D template matching operators to adapt to size changes caused by object distance variations.

Parameter Description

Height Range

Parameter Description

Possible height range of target object from camera. This range is used to calculate object pixel dimensions at different distances and affects the output "Scale Range". First value is minimum distance, second value is maximum distance.

Parameter Adjustment

Need to estimate or measure the nearest and farthest distances where workpieces may appear based on actual installation conditions, and fill in these two values. Accurate height range helps generate more appropriately sized templates and obtain useful scale range parameters for subsequent matching.

Parameter Range

[0, 10000], Default values: 1500, 3500, Unit: mm

Enable Fill

Parameter Description

Determines whether the generated shape is solid or only has outline.

Parameter Adjustment

If you want the template to be a solid shape, check this option.

GenerateTempleteImage 1

If you only need the shape’s border outline, leave unchecked.

GenerateTempleteImage 2

Image Edge Padding Ratio

Parameter Description

Size ratio of blank edges (background) added around the generated shape, ratio is calculated relative to the shape’s short side.

Parameter Adjustment

Increasing this value will make the generated template image larger with more blank areas around the shape. Appropriate blank edges help prevent the template image from being cropped due to rotation or slightly exceeding boundaries during subsequent template matching. Usually keep default value. If matching finds template edges too close to image boundaries causing unstable matching, can appropriately increase this value.

Parameter Range

[0, 1], Default value: 0.2

Line Thickness

Parameter Description

When "Enable Fill" is off, pixel thickness for drawing shape outline; when "Enable Fill" is on, this parameter is usually ineffective (except for text templates).

Parameter Adjustment

Only adjust when generating outline templates. Increasing this value makes outline lines thicker, decreasing makes them thinner. Choose an appropriate value based on the clarity and thickness of object edges in actual images.

Parameter Range

[1, 100], Default value: 1

Shape Specific Parameters

Parameter Description

Displayed according to selected "Template Type":

  • Rectangle:

    • Length: Long side dimension of rectangle (mm). Default: 20.

    • Width: Short side dimension of rectangle (mm). Default: 30.

  • Parallelogram:

    • Length: Base length of parallelogram (mm). Default: 20.

    • Height: Height of parallelogram (mm). Default: 20.

    • Acute Angle: Acute angle between side edge and base of parallelogram (degrees). Default: 30.

  • Isosceles Trapezoid:

    • Lower Base: Length of trapezoid’s lower base (mm). Default: 40.

    • Upper Base: Length of trapezoid’s upper base (mm). Default: 10.

    • Height: Height of trapezoid (mm). Default: 20.

  • Circle:

    • Circle Radius: Radius of circle (mm). Default: 10.

  • Concentric Circle:

    • Concentric Circle Inner Diameter: Inner circle radius (mm). Default: 10.

    • Concentric Circle Outer Diameter: Outer circle radius (mm). Default: 20.

  • Ellipse:

    • Major Axis: Major axis length of ellipse (mm). Default: 100.

    • Minor Axis: Minor axis length of ellipse (mm). Default: 30.

  • Text:

    • Text Size: Text size affecting generated text pixel height. Default: 30.

    • Text Content: Specific text string to generate. Default: "U"

Parameter Adjustment

Configure corresponding geometric dimension parameters according to selected template type.

Parameter Range

N/A