OpenCV HoughLines_1
The identical twin of HoughLines — same votes, same lines
- image
- lines
- nparray
HoughLines_1 is the second overload of cv2.HoughLines, and it's byte-for-byte the same node as HoughLines_0 - same nine inputs, same nparray output, same call under the hood. The pack's generator produced one node per Python binding of the function and didn't deduplicate the pair, so you get two entries in ComfyUI's search that behave identically. Use whichever; a workflow that saved HoughLines_1 works unchanged with HoughLines_0.
The actual algorithm
The Hough transform finds straight lines by letting edge pixels vote on (rho, theta) - every point on a real line agrees on one (rho, theta) pair, which wins the accumulator once it passes threshold. The node returns each detected line as [rho, theta] (distance from origin, angle in radians), shape (N, 1, 2).
The pipeline matters more than the node: it expects an 8-bit grayscale nparray on image, and you'll get the img.type() == CV_8UC1 assertion error if you feed it the 3-channel BGR output from Image2Nparray. The standard chain is Image2Nparray → cvtColor (code 6) → Canny_0 → HoughLines_1. Key knobs: threshold (votes required - the main sensitivity control), rho/theta (resolutions, start at 1.0 and 0.0174), and min_theta/max_theta (restrict the angle search to kill noise). use_edgeval (weight votes by edge strength) defaults off and is fine that way.
What comes out is geometry, not an overlay
These are infinite lines defined by [rho, theta], not segments. To draw them you compute endpoints and use the pack's line_0 node - there's no ready-made "visualize the lines" node (it's on the author's unfinished TODO list). For finite segments with start/end points and minLineLength/maxLineGap controls, that's HoughLinesP_0.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
or "OpenCV" via ComfyUI Manager, plus pip install opencv-contrib-python. No model files.
Bottom line
Don't spend any time choosing between _0 and _1 - they're the same function. Spend your time on the edge-detection chain in front of the node and on tuning threshold, because those are what actually decide whether you see lines or noise.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image | NPARRAY | — | |
| rho | FLOAT | — | |
| theta | FLOAT | — | |
| threshold | INT | — | |
| srn | FLOAT | — | |
| stn | FLOAT | — | |
| min_theta | FLOAT | — | |
| max_theta | FLOAT | — | |
| use_edgeval | BOOLEAN | — | |
| linesopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |