TemplateBuilder

Builder for the Template object

Constructor

Instance of this class can only be created via Template.image(), Template.color() or Template.text() methods.

Methods
value
TemplateBuilder value(value: string)

Set the name of the image, color or text value.

Parameters
value The template's value
Return
TemplateBuilder This TemplateBuilder instance
mScore
TemplateBuilder mScore(score: number)

Set min score when doing detection. This value will override the value in Param class.

Parameters
score The min score
Return
TemplateBuilder This TemplateBuilder instance
method
TemplateBuilder method(method: number)

Set the algorithm used for image detection, color detection will always use SQDIFF. This value will override the value in Param class.

Parameters
method The algorithm to use: 0 - CCOEFF, 1 - CCORR, 2 - SQDIFF
Return
TemplateBuilder This TemplateBuilder instance
segment
TemplateBuilder segment(mode: number)

Set the segment mode for text detection. This value will override the value in Param class.

Parameters
mode Segment Mode: 0 - word, 1 - line, 2 - paragraph
Return
TemplateBuilder This TemplateBuilder instance
mask
TemplateBuilder mask(mask: string | Template)

Provide a mask for this template. Mask is binary image with the same size as the template. All black value of the mask will be ignored when doing detection. Only image and color will use a mask.

Parameters
mask The mask for template
Return
TemplateBuilder This TemplateBuilder instance
offset
TemplateBuilder offset(dx: number, dy: number, noScale: bool)

Offset the click point that is used by click() method. The click point is the middle of the template if no offset is provided.

Parameters
dx Offset amount in x axis
dy Offset amount in y axis
noScale true to disable auto scaling. Default: false
Return
TemplateBuilder This TemplateBuilder instance
width
TemplateBuilder width(width: number)

Set the width of template. Only for color.

Parameters
width The width
Return
TemplateBuilder This TemplateBuilder instance
height
TemplateBuilder height(height: number)

Set the height of template. Only for color.

Parameters
height The height
Return
TemplateBuilder This TemplateBuilder instance
scale
TemplateBuilder scale(scale: number)

Scale the template. Only for image and color.

Parameters
scale Scale value. Default: 1
Return
TemplateBuilder This TemplateBuilder instance
scaleX
TemplateBuilder scaleX(scale: number)

Scale the template in horizontal direction. Only for image and color.

Parameters
scale Scale value. Default: 1
Return
TemplateBuilder This TemplateBuilder instance
scaleY
TemplateBuilder scaleY(scale: number)

Scale the template in vertical direction. Only for image and color.

Parameters
scale Scale value. Default: 1
Return
TemplateBuilder This TemplateBuilder instance
rotate
TemplateBuilder rotate(angle: number)

Rotate the template. Only for image and color.

Parameters
angle Rotate angle in radian
Return
TemplateBuilder This TemplateBuilder instance
gray
TemplateBuilder gray(grayscale: bool)

Grayscale the template. Only for image and color.

Parameters
grayscale true to convert template to grayscale
Return
TemplateBuilder This TemplateBuilder instance
threshold
TemplateBuilder threshold(threshold: number)

Threshold the template to create binary image. Only for image and color.

Parameters
threshold Threshold value from 0-255
Return
TemplateBuilder This TemplateBuilder instance
build
Template build()

Build the template.

Return
Template Template

© 2024 - Macrorify by KoK-CODE