OpenCV fitLine_1
Yes, fitLine_1 is the same as fitLine_0. Here's why that happens
- points
- line
- nparray
fitLine_1 is a duplicate of fitLine_0. Identical inputs, identical output, identical code under the hood in the current release. If that feels weird, good - it is weird, and it's the most honest thing about this pack, so let's get the story straight before the how-to.
This pack generates a node for every standalone OpenCV function, and for functions that have multiple overload signatures it generates one node per overload, numbered _0, _1, _2… Sometimes those overloads genuinely differ - different parameter sets, different behaviors. For fitLine, the two signatures OpenCV's stubs declare collapse into the same thing once the generator filters out the unsupported types. Result: two nodes that both call cv2.fitLine with the same arguments. You can use either; they're interchangeable.
What the node does
It fits a line through a set of 2D points. The inputs:
- points (
NPARRAY) - the 2D points, usually N×2(x, y)coordinates. - distType (
INT) - distance function for the fit:0L2,1L1,2L12,3FAIR,4WELSCH,5HUBER.0is the fast least-squares default; the robust ones resist outliers. - param (
FLOAT) - C parameter for the robust distances;0.0means "let OpenCV decide". - reps (
FLOAT) / aeps (FLOAT) - radial and angular accuracy; the0.01defaults are right for nearly everyone.
The optional line (NPARRAY) is an out-parameter the pack includes for OpenCV compatibility - the README tells you to ignore those, so ignore it.
The output is nparray: a 1×4 float array [vx, vy, x0, y0] - unit direction vector plus a point on the line. It's geometry, not an image, so don't feed it straight into Nparrays2Image or you'll get the pack's 'NoneType' object has no attribute 'shape' complaint.
Installing
Comes with geroldmeisinger/opencv-comfyui - one install, all ~635 nodes. ComfyUI Manager: search "opencv-comfyui". Or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
Restart ComfyUI. The pack installs opencv-contrib-python (plus numpy, torch) from its requirements.txt; bare envs may need pip install opencv-contrib-python.
Common issues
Same pack-wide gotchas: convert IMAGE ↔ NPARRAY with Image2Nparray/Nparrays2Image (single-image batches only), and make sure points holds coordinates rather than pixel arrays. If your fitted line gets dragged by outliers, that's a distType choice, not a bug.
The duplicate is worth remembering as a general warning about this pack: it's generated, not hand-made, and the author's README says so in so many words - "ugly and complex to use. Expect dragons!" When you see two identical nodes, that's the auto-generation showing its seams. Pick one, build your workflow, and don't go looking for a hidden difference between _0 and _1. There isn't one.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| points | NPARRAY | — | |
| distType | INT | — | |
| param | FLOAT | — | |
| reps | FLOAT | — | |
| aeps | FLOAT | — | |
| lineopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |