Nodes/opencv-comfyui/OpenCV Canny_1
ComfyUI Node

OpenCV Canny_1

Canny_1 — the same edge detector, same nodes, different number

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV Canny_1
  • image
  • edges
  • nparray
threshold1
threshold2
apertureSize
L2gradient

Before anything else: Canny_1 is a duplicate of Canny_0. Identical inputs, identical output, identical behavior. The opencv-comfyui pack mints one node per entry in OpenCV's type-definition file, and OpenCV declares Canny's image-based overload twice - once for MatLike, once for UMat - so the generator produced two copies and numbered them. There is nothing you can do with one that the other can't. Pick one, pin it in your workflow, move on.

If you came here cold, the short version: this node runs cv2.Canny, the canonical edge detector and one of the workhorse ControlNet preprocessors. It finds thin, hard edges - ideal for architectural shots, mechanical objects, and anything with clean contours - and its two thresholds are exposed as widgets so you can tune the edge density by hand.

What you set. image (NPARRAY) - must be a single-channel 8-bit grayscale image; feeding it color throws the README's classic img.type() == CV_8UC1 assertion error, so run cvtColor with code = 6 (BGR2GRAY) first. threshold1 and threshold2 (FLOAT) are the hysteresis bounds - pixels above threshold2 are definite edges, below threshold1 are discarded, and the middle band survives only if connected to a strong edge. Start around 100/200 and tune from there. apertureSize (INT, leave at 3) and L2gradient (BOOLEAN) are advanced; the optional edges input is an OpenCV out-parameter you can safely ignore. Output is a single nparray edge map, ready to feed a Canny ControlNet or convert back to an IMAGE with Nparrays2Image.

The pipeline shape to remember. This pack lives on the OpenCV side of the fence: ComfyUI IMAGE tensors are RGB 0..1 float32, OpenCV works in BGR 0..255 uint8 nparrays, and images are batch_size == 1 only. So the canonical chain is: ImageFromBatch (if needed) → Image2NparraycvtColor (BGR2GRAY, code 6) → this node → Nparrays2Image or a ControlNet.

Install: ComfyUI Manager, search "OpenCV", or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib

Restart after. No model downloads. And one honest warning from the author himself: the whole pack is auto-generated, the nodes are ugly, and "expect dragons." The duplicate-twin nodes are the friendly kind. If you want to argue with OpenCV's edge tuning, you've come to the right place - just use whichever Canny the graph suggests first.

Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
imageNPARRAY
threshold1FLOAT
threshold2FLOAT
apertureSizeINT
L2gradientBOOLEAN
edgesoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY