Nodes/opencv-comfyui/OpenCV rectangle_3
ComfyUI Node

OpenCV rectangle_3

Rectangle_3 — the rectangle node you'll never notice

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV rectangle_3
  • img
  • nparray
rec
color
thickness
lineType
shift

Let's be straight with you: rectangle_3 is the same node as rectangle_2, with a different number on it.

opencv-comfyui (geroldmeisinger/opencv-comfyui) generates its nodes by parsing OpenCV's type stubs and emitting one ComfyUI class per overload it finds. cv2.rectangle's Rect-based overload appears twice in those stubs (overloads with slightly different defaults), so you get two identical nodes: rectangle_2 and rectangle_3. The pack author says it plainly in the README: "Expect dragons." This is a dragon - not a bug, just generated noise.

So anything rectangle_2 does, rectangle_3 does identically: it draws a rectangle on an NPARRAY image, given a rec literal (x, y, width, height), a color scalar in BGR (yes, (0, 255, 0) is green), a thickness in pixels (negative fills), a lineType (8, 4, or 16 for anti-aliased), and a shift you'll leave at 0. Output is one nparray you feed into Nparrays2Image.

Installing it

Same as the rest of the pack - ComfyUI Manager (search "opencv-comfyui") or:

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

restart, and ensure opencv-contrib-python is installed:

pip install opencv-contrib-python

No models, no GPU, nothing exotic.

The practical take

If you find this node in your palette, just use whichever of rectangle_2/rectangle_3 you grabbed first and don't think about it. The numbered duplicates are a recurring feature of this pack - reduce_0/reduce_1, remap_0/remap_1, resize_0/resize_1 are all the same story. Once you know that, the dozens of near-identical nodes in the OpenCV category stop being intimidating and just become a search filter problem: type what you want, ignore the number, and remember that this whole pack works on numpy arrays, not ComfyUI IMAGE tensors, so Image2Nparray and Nparrays2Image are your gateways in and out.

The one trap shared by every rectangle node: the invalid syntax (<unknown>, line 0) error when a literal doesn't parse. Keep the parens. (10, 20, 100, 80), not 10, 20, 100, 80.

Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
imgNPARRAY
recSTRING
colorSTRING
thicknessINT
lineTypeINT
shiftINT

Outputs (1)

NameTypeDescription
nparrayNPARRAY