Nodes/comfyui_cv/CV Draw Flow Vectors
ComfyUI Node

CV Draw Flow Vectors

Debug helper: draws an arrow from each 'from' point to its matching 'to' point - the proper way to look at SPARSE optical flow / feature tracks (the equal-length, same-order point pairs that 'CV Track Features (KLT)' and 'CV Match Features' produce). Color the arrows by motion direction (the standard flow color wheel) or magnitude (a heatmap), or by cluster when labels are connected (for motion segmentation). None/empty inputs pass the image through unchanged and count=0; tiny motions below min_magnitude are skipped.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Draw Flow Vectors
  • source
  • points_from
  • points_to
  • labels
  • image
  • count
thickness1
color(0, 255, 0)
color_bydirection (color wheel)
tip_length0.30
min_magnitude0.00
max_magnitude0.00
magnitude_colormapCOLORMAP_VIRIDIS
Categoryimage/CV/points

Inputs (11)

NameTypeDefaultDescription
sourceCOMFY_MATCHTYPE_V3Image or mask to draw on (a copy is made). 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.
points_fromNPARRAYNx1x2 arrow tails - the points in the FIRST frame (e.g. 'Track Features (KLT)' points_a).
points_toNPARRAYNx1x2 arrow heads - the SAME points in the second frame (points_b); must match points_from in count and order.
thicknessINT11–64Arrow line width in pixels.
colorSTRING(0, 255, 0)Color as a single value (broadcast to all channels) or BGR tuple, e.g. '255' or '(0, 255, 0)'. Shorter tuples are zero-padded; longer tuples are truncated. Used only in 'fixed color' mode (and ignored when labels are connected).
color_byCOMBOdirection (color wheel)How to color each arrow: a single fixed color; by motion DIRECTION (hue = angle, the standard flow wheel - hue alone, so it is a picture to look at, not a key to read); or by MAGNITUDE, through 'magnitude_colormap' (dark = slow -> bright = fast, readable as brightness alone). Connecting labels overrides this with per-cluster colors.
tip_lengthoptFLOAT0.300–2Arrowhead length as a fraction of the shaft (cv2.arrowedLine tipLength).
min_magnitudeoptFLOAT0.000–1000000Skip arrows shorter than this many pixels - hides sub-pixel tracking jitter. 0 draws everything.
max_magnitudeoptFLOAT0.000–1000000Magnitude mapped to the hot end of the heatmap; larger clip. 0 = auto (this frame's longest vector) - set it to compare frames on one scale.
labelsoptNPARRAY(N,) integer labels: one color per cluster (e.g. motion segmentation), overriding color_by.
magnitude_colormapoptCOMBOCOLORMAP_VIRIDISRamp for the 'magnitude (heatmap)' mode. The default is perceptually uniform and rises monotonically in brightness, so slow-vs-fast survives colour blindness and greyscale; COLORMAP_JET is the familiar blue->red but does neither.

Outputs (2)

NameTypeDescription
imageCOMFY_MATCHTYPE_V3Same format as the image input.
countINTHow many arrows were drawn (after the min_magnitude filter) - branch on it with if/else for the nothing-moved case.