ComfyUI Node
CV Match Template Multi-Scale
Template matching when the size in the image is unknown: tries a range of template scales and keeps the best match - the usual workaround for matchTemplate not being scale-invariant, packed into one node instead of a loop. Restricted to normalized methods so scores are comparable across scales. Chain bbox into the core 'Draw BBoxes' node to visualize the match. Also accepts LATENT pairs (coordinates then count latent cells).
CV Match Template Multi-Scale
- image
- template
- template_mask
- match_crop
- score
- best_scale
- bbox
◄methodTM_CCOEFF_NORMED►
◄scale_min0.25►
◄scale_max2.00►
◄scale_steps20►
Categoryimage/CV
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMFY_MATCHTYPE_V3 | Image to search in. Accepts a LATENT too (then the template must be a LATENT from the same model and match_crop comes back as a LATENT). | |
| template | IMAGE,LATENT | Patch to search for. Same kind as 'image': IMAGE with IMAGE, LATENT with LATENT. | |
| method | COMBO | TM_CCOEFF_NORMED | Normalized comparison method. TM_CCOEFF_NORMED is the most robust general choice; all three give scores comparable across scales. |
| scale_min | FLOAT | 0.250.01–8 | Smallest template scale to try. |
| scale_max | FLOAT | 2.000.01–8 | Largest template scale to try. |
| scale_steps | INT | 202–100 | Number of scales tried between scale_min and scale_max (geometric spacing). More steps = more precise, slower. |
| template_maskopt | MASK | Optional mask for non-rectangular templates (white = compare). Resized along with the template at each scale. Only supported by TM_CCORR_NORMED. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| match_crop | COMFY_MATCHTYPE_V3 | The matched region, in the 'image' input's format (IMAGE in -> IMAGE crop, LATENT in -> LATENT crop). |
| score | FLOAT | Best confidence across all scales (higher = better). |
| best_scale | FLOAT | Template scale that produced the best match. |
| bbox | BOUNDING_BOX | Core BOUNDING_BOX data: per-frame lists of {x, y, width, height} dicts - compatible with Draw BBoxes, Crop By Bounding Boxes, Image Crop, etc. The match region; includes the score and scale as extra keys. A list of per-image boxes for batches. |