Nodes/opencv-comfyui/OpenCV boundingRect_1
ComfyUI Node

OpenCV boundingRect_1

The same box math, the redundant twin

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV boundingRect_1
  • array
  • literal

OpenCV boundingRect_1 is the second auto-generated overload of cv2.boundingRect, and it is byte-for-byte the same node as boundingRect_0. OpenCV's Python stubs declare the function twice with slightly different signatures; opencv-comfyui, which mints a node per overload, shipped both. Pick whichever your muscle memory finds first. The _1 tells you nothing about behavior.

The function itself is genuinely useful in the right spot. Feed it an (N, 2) point set - detection corners, optical-flow track points, the 4×2 output of boxPoints - and it returns the tightest axis-aligned (x, y, width, height) box around all of them. That's the rectangle that lets you turn "a scattered set of points" into "a region I can crop or mask." In the detailing/mask ecosystem, a bbox is the crudest but most universal region shape, and every deterministic CV pipeline reaches for it.

Inputs and output

  • array - one NPARRAY: the (N, 2) float point set. Same convention as every node in this pack: BGR-era numpy, uint8-world, converted through Image2Nparray if your points came from an image.
  • Output - a literal STRING, e.g. (5, 8, 120, 200). The generator had no widget for OpenCV's Rect type, so it serialized the result as text. That means no clean plug-into-a-crop-node path: you read the four numbers out of the string and enter them where your crop wants them. It's the pack's known ugliness, stated right in the README.

Install and the usual traps

ComfyUI Manager → opencv-comfyui, or clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes and restart. Needs opencv-contrib-python, which is almost certainly already on your box.

The one real trap is scope: this node wants a point set, not a mask. If you've got a binary mask and you want its bounding box, cv2.boundingRect is not the function for it (you'd want to find the mask's contour or non-zero pixels first) - so don't be surprised when feeding a mask errors or returns nonsense. And as with the whole pack: batch size 1, NPARRAY in means you own the color/type conventions. It's a quiet, deterministic geometry node - exactly what the pack's author said these are for: small, quick, non-AI transformations inside a bigger graph.

Categoryimage/OpenCV

Inputs (1)

NameTypeDefaultDescription
arrayNPARRAY

Outputs (1)

NameTypeDescription
literalSTRING