Nodes/opencv-comfyui/OpenCV HoughLinesPointSet_0
ComfyUI Node

OpenCV HoughLinesPointSet_0

Finding lines in a scatter of points, not an image

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV HoughLinesPointSet_0
  • point
  • lines
  • nparray
lines_max
threshold
min_rho
max_rho
rho_step
min_theta
max_theta
theta_step

HoughLinesPointSet_0 is the Hough transform's nerdier cousin: instead of finding lines in an image, it finds lines in a set of points. You hand it an array of coordinates and it answers "which of these points form straight lines?". It's one of the more obscure nodes in the opencv-comfyui pack, and odds are you've never needed it - but if you're fitting lines to detected keypoints, corner positions, or any point cloud that isn't rendered as pixels, this is the tool.

How it works

Same voting math as HoughLines_0 - every point votes for the (rho, theta) lines passing through it, and lines with enough votes win - but the input is a raw point list rather than a 2D edge map. That means it never looks at pixel intensity; it only cares about geometry.

The catch is the input format. OpenCV's HoughLinesPointSet expects a specific nparray: shape (N, 1, 2), float32, each element a (x, y) coordinate. This is a genuinely awkward requirement inside ComfyUI, because nothing in the pack's default flow produces a (N, 1, 2) float32 array for you - you'd need to construct one upstream (the pack's nodes produce images or scalar results, not point lists). This is squarely in the "auto-generated, expect dragons" territory the README warns about.

The inputs that matter

  • point (NPARRAY) - the (N, 1, 2) float32 coordinate array.
  • lines_max (INT) - maximum number of lines to return.
  • threshold (INT) - minimum votes a line needs. Raise to require more supporting points.
  • min_rho / max_rho (FLOAT) - range of distances from origin to search, in the same units as your coordinates.
  • rho_step (FLOAT) - resolution of the distance axis.
  • min_theta / max_theta (FLOAT) - angle range to search, radians.
  • theta_step (FLOAT) - resolution of the angle axis.

Output nparray is the detected lines, shape (N, 1, 2) of [rho, theta] - same representation as HoughLines_0. Optional lines input is the generator's out-parameter; leave it disconnected.

When you'd actually use it

Honestly: rarely, and mostly in computer-vision-research-style workflows. Think "given a pile of corner detections, find the grid lines" or "fit lines to tracked feature points". For the normal ComfyUI case - you have an image and want to find lines in it - you want HoughLinesP_0 or HoughLines_0 with a Canny edge map in front. This node exists because the pack wraps every top-level OpenCV function; not everything is a good fit for a graph.

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 models.

Gotchas

The point-array format is the entire battle. If you get a TypeError about the input shape or type, that's the (N, 1, 2) float32 requirement biting you. And remember the coordinate units for min_rho/max_rho are whatever your points use - don't guess pixels if your points live in another space. If you're a beginner, skip this node until the day you actually hold a point cloud in your hands; the image-based Hough nodes will cover 99% of what you want.

Categoryimage/OpenCV

Inputs (10)

NameTypeDefaultDescription
pointNPARRAY
lines_maxINT
thresholdINT
min_rhoFLOAT
max_rhoFLOAT
rho_stepFLOAT
min_thetaFLOAT
max_thetaFLOAT
theta_stepFLOAT
linesoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY