OpenCV HoughLinesP_1
The duplicate of the line-segment detector — use either one
- image
- lines
- nparray
HoughLinesP_1 is the second overload of cv2.HoughLinesP and it is indistinguishable from HoughLinesP_0 - same six inputs, same nparray output of [x1, y1, x2, y2] segments, same function call. The opencv-comfyui generator emits one node per Python binding and left this duplicate in place. If a workflow asks for HoughLinesP_1, this is the node it wants - and _0 works just as well if you build fresh.
What it actually does
Probabilistic Hough line detection: edge pixels vote for candidate lines, a random subset is sampled to save compute, and each accepted line is walked along to find where real edge support begins and ends. The result is finite segments with start/end coordinates, which is why it beats the plain HoughLines_* nodes for document edges, lane lines, and anything where you need the endpoints rather than an infinite line.
The inputs that matter, same as _0:
image(NPARRAY) - grayscale edge map, not the raw BGR image. Feed it 3-channel and you'll hitimg.type() == CV_8UC1.threshold(INT) - votes required per line; the main sensitivity knob.minLineLength(FLOAT) - drop segments shorter than this (pixels). Your best noise filter.maxLineGap(FLOAT) - merge segments separated by gaps up to this size.
rho and theta are resolution settings - 1.0 and 0.0174 (one degree) are the standard starting values.
The pipeline around it
Image2Nparray → cvtColor (code 6 = BGR2GRAY) → Canny_0 → HoughLinesP_1. OpenCV's Hough functions don't detect edges themselves; they vote on the edge map you give them. And the output is raw geometry - to see the segments you draw them with the pack's line_0 node, since there's no built-in overlay helper (it's on the author's TODO list).
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 anywhere.
Bottom line
Don't agonize over _0 vs _1 - they're the same function, pick whichever ComfyUI surfaces. The real work in line detection is the grayscale + Canny chain in front of it and tuning threshold/minLineLength behind it. Start strict and loosen up; that's the whole game.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | NPARRAY | — | |
| rho | FLOAT | — | |
| theta | FLOAT | — | |
| threshold | INT | — | |
| minLineLength | FLOAT | — | |
| maxLineGap | FLOAT | — | |
| linesopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |