Nodes/opencv-comfyui/OpenCV selectROI_2
ComfyUI Node

OpenCV selectROI_2

The ROI picker that skips the window name

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV selectROI_2
  • img
  • literal
showCrosshair
fromCenter
printNotice

selectROI_2 is the version of OpenCV's cv2.selectROI that doesn't make you name the window. Same interactive dance - a window pops up, you drag a rectangle over the image, press Enter/space to confirm or c to cancel - but windowName is dropped from the inputs entirely, so OpenCV uses its default title. It's the slightly less ceremonious sibling of selectROI_0.

Inputs and outputs

Inputs here: img (NPARRAY), plus the three booleans showCrosshair (crosshair in the box), fromCenter (drag from center instead of a corner), and printNotice (print the drag instructions to the console). Output is a STRING-labeled literal that, true to this pack's nature, actually carries the raw (x, y, w, h) rectangle tuple from OpenCV - so whatever you wire it into needs to tolerate a tuple, not a text string. That's the standing "expect dragons" tax.

Gotchas

The honest framing from selectROI_0 applies here too: this node blocks the graph until you interact, it requires a real display (a headless server or Docker container has no window to show, so the call errors), and it only accepts batch_size==1 images on the way in. It's a manual, one-off tool - great for picking a crop or detailing region by eye, wrong for anything automated.

Why it exists

Why does this overload exist? OpenCV ships two selectROI signatures - one that takes a window name and one that doesn't - and the pack's generator numbered every overload it found, then doubled each for the MatLike/UMat type variants. So selectROI_2 (numpy, no window name) and selectROI_3 (UMat, no window name) are this branch, and selectROI_0/1 are the named-window branch. From the UI, _2 and _3 are interchangeable, and the only real difference from _0/_1 is whether you get to title the popup.

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

If you're choosing, the named-window variant is marginally nicer when you have several ROI popups in one workflow and want to tell them apart. Otherwise this one is fine and identical in behavior.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
imgNPARRAY
showCrosshairBOOLEAN
fromCenterBOOLEAN
printNoticeBOOLEAN

Outputs (1)

NameTypeDescription
literalSTRING