Nodes/comfyui_cv/cv2.warpAffine
ComfyUI Node

cv2.warpAffine

Raw wrapper of cv2.warpAffine(src, M, dsize, flags?, borderMode?, borderValue?, hint?). 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.warpAffine
  • src
  • M
  • dsize
  • result
flagsINTER_LINEAR
borderModeBORDER_DEFAULT
borderValue
hintALGO_HINT_DEFAULT
Categoryimage/CV/low-level/cv2 W

Inputs (7)

NameTypeDefaultDescription
srcCOMFY_MATCHTYPE_V3input image. The image output(s) echo this input's format. 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.
MNPARRAY$2\times 3$ transformation matrix. A data array (points / matrix), NOT an image - only an NPARRAY link is accepted here.
dsizeCV_TUPLE0,0size of the output image. One value with 2 components (w, h) - it travels as a whole, so it cannot arrive half-connected. Wire it from 'CV Tuple' or type the components in place.
flagsoptSTRINGINTER_LINEARcombination of interpolation methods (see #InterpolationFlags) and the optional flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( $\texttt{dst}\rightarrow\texttt{src}$ ). cv2.warpAffine flags: one of INTER_LINEAR, INTER_NEAREST, INTER_CUBIC, INTER_LANCZOS4 plus any of WARP_INVERSE_MAP, WARP_FILL_OUTLIERS, pipe-joined (e.g. "INTER_LINEAR | WARP_INVERSE_MAP"). In the UI this renders as a dropdown with one toggle per flag.
borderModeoptCOMBOBORDER_DEFAULTpixel extrapolation method (see #BorderTypes); when borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function.
borderValueoptSTRINGvalue used in case of a constant border; by default, it is 0. cv2 Scalar as a literal, e.g. "(0, 255, 0)" (BGR) or "(0, 255, 0, 64)" (BGRA). A bare number broadcasts to every component, so "255" means (255, 255, 255, 255). Components past the target's channel count are ignored by OpenCV. Leave blank for the OpenCV default.
hintoptCOMBOALGO_HINT_DEFAULTImplementation modification flags. Set #ALGO_HINT_APPROX to use FP16 precision (if available) for linear calculation for faster speed. See #AlgorithmHint.

Outputs (1)

NameTypeDescription
resultCOMFY_MATCHTYPE_V3Echoes the 'src' input's format: an IMAGE link comes back as IMAGE, MASK as MASK, NPARRAY stays NPARRAY.