Template matching parameters for Region.
Syntax
ScaleParam(grayscale=True, auto_scale=False, cache_scale=True, template_scale="SHORT_EDGE", fast_matching=False)Constructor parameters
| Name | Description |
|---|---|
grayscaleBoolean | **Applies to templates**. Convert template matching to grayscale. Optional · Positional or named Default: True |
auto_scaleBoolean | Try template sizes with an adaptive 0.70x-1.30x edge range after the configured template scale. Optional · Positional or named Default: False |
cache_scaleBoolean | Cache successful auto-scale values. Optional · Positional or named Default: True |
template_scaleString | Values: SHORT_EDGE, LONG_EDGE, DPI, SMALLEST_WIDTH_DP, NONE. Optional · Positional or named Default: SHORT_EDGE |
fast_matchingBoolean | Downsample both the Region image and template to two thirds before matching. This is faster but may slightly reduce accuracy, especially for small icons. Optional · Positional or named Default: False |
Returns
ScaleParamBehavior / side effects
Template matching parameters for Region. fast_matching downsamples both the Region image and template.
Execution
- Blocking: No
- Thread safety: Use separate objects per flow
- Parallel execution: Yes
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Configure matching preprocessing on this Region
settings = ScaleParam(grayscale=True, fast_matching=True)
region = Region(100, 200, 300, 400, scale_param=settings)
print(region.find("start", timeout=0).found)Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Related APIs
None
Fields
| Name | Description |
|---|---|
grayscaleBoolean | **Applies to templates**. Convert screenshot/template to grayscale before template matching. Default: True |
auto_scaleBoolean | Try template sizes around the configured scale with an adaptive range: high DPI/resolution scans smaller candidates down to 0.70x, while low DPI/resolution scans larger candidates up to 1.30x. Default: False |
cache_scaleBoolean | Cache the first successful auto-scale value for later runs. Only applies when auto_scale is True. Default: True |
template_scaleString | Base template scale mode. Values: SHORT_EDGE, LONG_EDGE, DPI, SMALLEST_WIDTH_DP, NONE. Default: SHORT_EDGE |
fast_matchingBoolean | Downsample both the Region image and template to two thirds before matching. This is faster but may slightly reduce accuracy, especially for small icons. Default: False |
Field example
param = ScaleParam(auto_scale=True, template_scale="LONG_EDGE", fast_matching=True)
param.cache_scale = False
template_mode = param.template_scaleConstructor example
param = ScaleParam(grayscale=True, auto_scale=True, cache_scale=True, template_scale="LONG_EDGE", fast_matching=True)
quick = ScaleParam(False, True, True, "LONG_EDGE", True)