Nodes/Nodes for use with real-time applications of ComfyUI/Integer Motion Controller πŸ•’πŸ…‘πŸ…£πŸ…
ComfyUI Node

Integer Motion Controller πŸ•’πŸ…‘πŸ…£πŸ…

Motion Detection, but the Output Counts Whole Numbers

By ryanontheinsideΒ·Created 2 years agoΒ·Updated about a year agoΒ· 82
Integer Motion Controller πŸ•’πŸ…‘πŸ…£πŸ…
  • image
  • roi_chain
  • INT
  • MASK
β—„always_executetrueβ–Ί
β—„threshold0.10β–Ί
β—„blur_size5β–Ί
β—„minimum_value0β–Ί
β—„maximum_value100β–Ί
β—„starting_value0β–Ί
β—„rounding_moderoundβ–Ί

Motion Controller's integer sibling. Integer Motion Controller watches a frame for motion, but instead of a smooth float it hands you a whole number - which makes it the node to reach for when the thing you're driving wants discrete values. Think counters, stage indices, preset slots, or anything that steps rather than glides.

It inherits everything from Motion Controller: frame-differencing against the previous frame, Gaussian blur (blur_size), a threshold for what counts as motion, and an roi_chain of regions of interest from an ROINode. Each ROI carries an action - trigger, momentary, toggle, counter, or the math ops add/subtract/multiply/divide/set - and that action decides how the value changes when motion is detected in that region. The one real addition is rounding_mode, and it's where the integer-ness gets interesting.

rounding_mode offers four ways to convert the internal float to an int: round (nearest, the default), floor (always down), ceil (always up), and truncate (chop the decimal). It sounds pedantic, but it changes the feel of an effect. If your ROI action is add with a tiny value, ceil makes the count climb fast while floor makes it stick stubbornly low; if you're mapping motion to a discrete effect, picking the right rounding is half the tuning.

The inputs that matter

  • roi_chain - the ROI from an ROINode; defines where motion counts and what it does.
  • image - the frame to analyze.
  • threshold - sensitivity, 0–1.
  • minimum_value / maximum_value - the integer output range (defaults 0–100). counter in particular uses this range to wrap its count.
  • rounding_mode - round, floor, ceil, or truncate.

Outputs: INT and MASK (the motion mask, same as the float version).

Install & gotchas

Same pack, ryanontheinside/ComfyUI_RealtimeNodes - ComfyUI Manager (search "Control Nodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/ryanontheinside/ComfyUI_RealtimeNodes
cd ComfyUI_RealtimeNodes
pip install -r requirements.txt

All the Motion Controller caveats apply: it's stateful and needs to run every frame, so a single still image produces no motion by definition; it clamps to min/max; and too-low a threshold turns webcam noise into jitter. The integer twist adds one more: because the value is quantized, small changes in motion can snap the output between adjacent integers - that's the rounding doing its thing, not a glitch. If you wanted smooth motion feeding a continuous parameter, you picked the wrong one of the pair. If you want "wave and it advances a preset by one," this is exactly right.

Categoryreal-time/control/motion

Inputs (9)

NameTypeDefaultDescription
always_executeBOOLEANtrueWhen enabled, the node updates every execution
imageIMAGEβ€”
roi_chainROIβ€”
thresholdFLOAT0.100–1Motion detection threshold
blur_sizeINT51–21Size of Gaussian blur kernel
minimum_valueINT0Minimum output value
maximum_valueINT100Maximum output value
starting_valueINT0Initial output value
rounding_modeCOMBOround4 options: round, floor, ceil, truncate

Outputs (2)

NameTypeDescription
INTINTβ€”
MASKMASKβ€”