Nodes/opencv-comfyui/OpenCV getWindowImageRect_0
ComfyUI Node

OpenCV getWindowImageRect_0

Window geometry for a window that's never opened

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV getWindowImageRect_0
    • literal
    winname

    getWindowImageRect_0 wraps cv2.getWindowImageRect, a function that reports the on-screen rectangle of an image inside an OpenCV GUI window. One input - winname (STRING), the window's name - and one output: a literal (STRING) with the rect as a Python tuple, like (200, 100, 640, 480). In a desktop OpenCV script that's useful: you dragged a window around, resized it, and you want to know where the image actually sits on screen. In ComfyUI, there's a small problem: none of that exists.

    Why it's a dead end in ComfyUI

    OpenCV's window functions belong to HighGUI, the desktop GUI toolkit that pops native windows on the machine running the code. getWindowImageRect reads the state of a window you'd have created with namedWindow and fed with imshow - the interactive "here's a live preview, drag it around" workflow. ComfyUI runs as a server, usually headless, and its previews render in the browser, not in native OpenCV windows. There is no window named winname, so there is nothing to measure. The node either errors out or returns nothing meaningful depending on your build.

    This one isn't even a slightly-different-looking case of getTrackbarPos_0 - it's the same disease. HighGUI functions assume a desktop session with a display and an event loop. The graph gives you neither.

    The only scenario where it's not useless

    If you're running ComfyUI on a local desktop machine with a display and you've manually created an OpenCV window in your own code or another custom node (some packs use imshow for previews), then getWindowImageRect_0 could read that window's geometry. That's a narrow, fragile setup - the window has to exist and be named exactly what you type, and another node's behavior becomes a hidden dependency. Don't design a workflow around this. If you need to know the dimensions of an image, ComfyUI already knows - any image node's width/height are right there in the graph.

    Install

    Standard pack install, nothing special:

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

    or ComfyUI Manager, search "opencv-comfyui", restart. Depends on opencv-contrib-python (numpy and torch ship with ComfyUI). No models, no keys.

    The honest verdict

    This is a museum node - a faithful, literal port of a function whose environment ComfyUI doesn't provide. The pack's README warns "not every function is useful within ComfyUI without further processing," and the whole HighGUI window family is the clearest example. Knowing what it is saves you the confusion of seeing it in your node list and wondering whether you're missing a feature. You're not. It's the auto-generator being thorough about something that shouldn't have been wrapped.

    Categoryimage/OpenCV

    Inputs (1)

    NameTypeDefaultDescription
    winnameSTRING

    Outputs (1)

    NameTypeDescription
    literalSTRING