OpenCV selectROI_0
Click and drag a region mid-workflow
- img
- literal
selectROI_0 is the node that stops your workflow and asks you to draw a box. It wraps cv2.selectROI: a native OpenCV window pops up with your image, you click and drag to select a region, press Enter (or space) to confirm or c to cancel, and the node hands the rectangle back to the graph. It's the interactive exception in an otherwise fully-automated pack - and it's the one node here that genuinely can't be replaced by typing numbers.
Why you'd want it
When would you want that in ComfyUI? Whenever the region is something you decide by looking, not something computed: pick a crop target for an inpainting or upscaling pass, select the face you want to detail, choose the focal area for the next stage. Instead of hand-typing coordinates into a crop widget, you look at the image and draw. It's the closest thing this pack has to an interactive tool, and for one-off manual work it's genuinely pleasant.
Inputs and outputs
Mechanically it's straightforward. Required inputs: windowName (STRING - the title of the popup window, pick something you'll recognize), img (NPARRAY - the image you're selecting on), and three booleans: showCrosshair (draw a crosshair in the box), fromCenter (drag from the box's center instead of a corner), and printNotice (print instructions to the console). Output is labeled literal and typed STRING.
The dragon
Here's the dragon, stated plainly: the output is declared as a STRING "literal", but what actually comes back is the raw rectangle tuple (x, y, w, h) from OpenCV. The pack represents composite types as literals everywhere else, but this node doesn't serialize the tuple for you - so wiring it into a node that expects a text string will blow up. You'll need a consumer that can handle a tuple, or you'll read the coordinates off and type them elsewhere. It's ugly, and it's the kind of thing the author's "expect dragons" warning is about.
The bigger gotcha is that this node blocks. It opens a real window and waits for your mouse, so your whole graph stalls until you click. And it needs a display: headless ComfyUI (a Docker box, a remote server, a VPS) has no window to show, so the call throws. On a normal desktop it works, but don't put it in an automated or batch pipeline. Also remember Image2Nparray only accepts batch_size==1, so feed it a single frame.
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
Install: ComfyUI Manager → search "opencv-comfyui", or the commands above, then pip install opencv-contrib-python for the dependency - no model downloads.
Verdict
Fair verdict: it's the most interactive node in the pack and the selectROI_0/selectROI_1 pair (the named-window variants) is the one you want if you're choosing. But between the blocking behavior, the headless failure, and the tuple-in-a-STRING-socket output, it's also the clearest demonstration of why this pack is for people comfortable with dragons. If you just need to crop, a plain crop node with typed coordinates is less drama.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| windowName | STRING | — | |
| img | NPARRAY | — | |
| showCrosshair | BOOLEAN | — | |
| fromCenter | BOOLEAN | — | |
| printNotice | BOOLEAN | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| literal | STRING | — |