Nodes/ComfyUI CV/cv2.currentUIFramework
ComfyUI Node

cv2.currentUIFramework

What UI is OpenCV built against? (in a headless build, nothing)

By bmad4ever·Created 3 months ago·Updated 14 days ago· 1
cv2.currentUIFramework
    • string

    cv2.currentUIFramework answers one question: which windowing framework is this OpenCV build wired to - GTK, Qt, Win32, Cocoa - or none at all. In the ComfyUI CV pack it's a node with zero inputs and one STRING output, which makes it the purest "build introspection" node in the pack, and honestly the least useful one for image work.

    Here's the catch, and it's the whole story for ComfyUI users: the pack declares opencv-contrib-python-headless as its dependency, and headless means the build has no highgui windowing at all. No imshow, no waitKey, no trackbars - the pack's registry generator blacklists those functions outright. So on the build this pack is curated against, there is no UI framework to report, and you should expect an empty or "none"-ish answer rather than a proud "GTK 3". If you're running a full desktop opencv-contrib-python because something else in your custom_nodes tree installed it, you may get a real name back.

    Why you'd still press Run on it

    Because "which cv2 am I actually importing?" is a real question in ComfyUI, and it's the same question this node's output gestures at. Every OpenCV distribution - opencv-python, opencv-python-headless, opencv-contrib-python, opencv-contrib-python-headless - installs into the same site-packages/cv2. Install one over the other and you don't get two libraries; you get whichever won, with its own feature set. That's the accident bmad4ever's README warns about, and why the pack ships tools/repair_opencv_contrib.py: a non-contrib wheel silently empties the contrib submodules and the contrib nodes stop loading with no error that names the cause.

    cv2.currentUIFramework is a one-line probe in that investigation. The better instrument in the same pack is CV Build Information, which prints the whole OpenCV build banner with local paths redacted - Eigen support, non-free modules, OpenCL, CUDA, the version string. If you're debugging "why did my ximgproc nodes vanish", run that node before you reinstall anything.

    It's also a tidy example of the pack's shape: ~470 auto-generated cv2.* wrappers plus curated nodes, generated from the cv2 type stubs, so anything that's a top-level function becomes a node whether or not anyone wants it. The author says as much in the README - raw wrappers are uncurated, expect to handle the edge cases yourself.

    Inputs and outputs

    None in. The output is a STRING named string, and it's a plain ComfyUI string, so it wires into any text-display node - Preview as Text in this pack, or a core show-text node. There is nothing to configure and no image involved.

    If you want the same information without loading a workflow, you can ask Python directly:

    # from your ComfyUI venv, in the ComfyUI directory
    python -c "import cv2; print(cv2.__file__); print(cv2.__version__); print(cv2.currentUIFramework())"
    

    That prints the actual file being imported, which settles "which wheel won" faster than any node. This is worth doing once, before you file a bug against a pack whose nodes refuse to appear.

    Installing it

    ComfyUI Manager → search the pack title (ComfyUI CV) → install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bmad4ever/comfyui_cv
    pip install "opencv-contrib-python-headless~=5.0.0.93"
    

    Python ≥ 3.12 and a ComfyUI recent enough to have the V3 node API - the pack is a rewrite on that API, not on the old NODE_CLASS_MAPPINGS style, so an older ComfyUI is a hard fail rather than a degraded experience.

    One more install-time warning, the one people actually hit: that pin pulls numpy 2.x, and the ecosystem's long-running conflict is insightface 0.7.3 (numpy 1.x) against any modern opencv wheel (numpy 2.x). The relevant thread is a user trying to satisfy both for a day and a half, and the follow-up advice in it - "check your requirements.txt, if numpy got bumped to >2.0 your insightface is secretly broken" - is the kind of thing worth knowing before you install a CV pack into a FaceID workflow.

    Common issues and troubleshooting

    The output is blank. That's the headless build being honest: no windowing framework is compiled in, so there's nothing to name. It is not a broken node.

    cv2.currentUIFramework() raises AttributeError. Some builds don't expose it, or you're on an old OpenCV. The pack's registry is generated against the installed cv2 and skips functions the build doesn't have, so if the node is missing from your node list, that's the mechanism - not a failed install.

    Nodes from this pack are missing generally. Check for a competing non-contrib opencv wheel first (python -c "import cv2; print(cv2.__file__)"), then run tools/repair_opencv_contrib.py --check. Restart ComfyUI after any wheel change; the node list is built at import time.

    Categoryimage/CV/low-level/cv2 C

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    stringSTRING—