Nodes/comfyui_cv/cv2.matchTemplate
ComfyUI Node

cv2.matchTemplate

Raw wrapper of cv2.matchTemplate(image, templ, method, mask?). Parameters marked '?' are optional; blank means OpenCV default. See the OpenCV documentation for details.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
cv2.matchTemplate
  • image
  • templ
  • mask
  • nparray
methodTM_CCOEFF_NORMED
Categoryimage/CV/low-level/cv2 M

Inputs (4)

NameTypeDefaultDescription
imageNPARRAY,IMAGE,MASK,LATENTImage where the search is running. It must be 8-bit or 32-bit floating-point. A LATENT link is processed in latent space: frame 0 becomes a float32 [H,W,C] array (any channel count), values untouched. Arithmetic ops (add, multiply, etc.) also accept a full LATENT batch ({samples: [B,C,H,W]}) — the whole batch flows through when both inputs have the same batch size. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.
templNPARRAY,IMAGE,MASK,LATENTSearched template. It must be not greater than the source image and have the same data type. A LATENT link is processed in latent space: frame 0 becomes a float32 [H,W,C] array (any channel count), values untouched. Arithmetic ops (add, multiply, etc.) also accept a full LATENT batch ({samples: [B,C,H,W]}) — the whole batch flows through when both inputs have the same batch size. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.
methodCOMBOTM_CCOEFF_NORMEDParameter specifying the comparison method, see #TemplateMatchModes
maskoptNPARRAY,IMAGE,MASKOptional mask. It must have the same size as templ. It must either have the same number of channels as template or only one channel, which is then used for all template and image channels. If the data type is #CV_8U, the mask is interpreted as a binary mask, meaning only elements where mask is nonzero are used and are kept unchanged independent of the actual mask value (weight equals 1). For data type #CV_32F, the mask values are used as weights. The exact formulas are documented in #TemplateMatchModes. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.

Outputs (1)

NameTypeDescription
nparrayNPARRAY