Nodes/opencv-comfyui/OpenCV waitKey_0
ComfyUI Node

OpenCV waitKey_0

The keyboard-wait node that mostly just blocks your graph

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV waitKey_0
    • int
    delay

    In plain Python, cv2.waitKey(delay) is the line that makes an OpenCV GUI tick - it pauses for delay milliseconds, watches for a keypress, and returns the key code (or -1 if nothing was pressed). Inside ComfyUI, it's a function from a completely different world, and it shows. waitKey_0 takes one INT (delay), blocks the graph for that many milliseconds, and returns an INT key code that, in practice, is almost always -1. It's one of the clearest examples of this pack's "expect dragons" policy: auto-generated from OpenCV's stubs, technically functional, and barely meaningful inside a node graph.

    How it works

    waitKey is married to OpenCV's highgui window system. It only "sees" keypresses that happen while an OpenCV window has focus - which means it's only useful if you're also running imshow (this pack ships imshow_0 too) on a machine with a real display. Run ComfyUI headless or in the browser (which is most of us, including anyone on a remote box), and there's no window, no focus, no key events. The node then just sleeps for delay ms and returns -1, every time.

    So the realistic use is as a crude timer: wire delay to however long you want to pause, and let the graph stall. It's a legitimate (if slightly unhinged) way to pace an animation loop or throttle API calls, and the return value is just noise you ignore.

    Inputs and outputs

    • delay (INT) - milliseconds to wait. 0 means "wait forever" in desktop OpenCV; inside ComfyUI that would hang your queue, so don't. Use small positive numbers.
    • Output: int - the key code, or -1 when no key was pressed. Nothing in this pack consumes it; it's informational.

    Installing

    Pack-wide standard: ComfyUI Manager, search "opencv-comfyui", install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/geroldmeisinger/opencv-comfyui
    

    requirements.txt covers opencv-contrib-python, numpy, torch.

    Should you use it?

    If you're looking for a delay node, there are nicer, purpose-built ones that don't smuggle a keyboard event system into your graph. If you're trying to interactively inspect images mid-pipeline - press a key to advance frames - the honest answer is that ComfyUI's own frontend already does that better, and pairing imshow_0 with waitKey_0 inside a workflow fights the architecture. The one setup where this node makes sense is a local, desktop ComfyUI where you genuinely want an OpenCV GUI window to pop up and wait for you. That's a narrow door. Walk through it only if you know you're on that side.

    Categoryimage/OpenCV

    Inputs (1)

    NameTypeDefaultDescription
    delayINT

    Outputs (1)

    NameTypeDescription
    intINT