OpenCV findNonZero_1
FindNonZero's twin — a point list, either way
- src
- idx
- nparray
OpenCV findNonZero_1 is the UMat twin of findNonZero_0, which means it's the same node under a different name. Same single required input (src, a single-channel NPARRAY), same optional idx out-parameter, same single output: an Nx1x2 array of (x, y) coordinates for every non-zero pixel. The duplicate is a byproduct of the pack auto-generating nodes for both the MatLike and UMat overloads in OpenCV's type stubs. There's nothing to prefer between them.
The substance lives in the _0 article, but here's the quick version: findNonZero scans a single-channel image or mask and hands back where the non-zero pixels are - the raw material for centroid math, bounding boxes, and shape fitting. Feed its output to minAreaRect or fitEllipse and you've got a quick "fit a shape around the bright stuff" pipeline.
What to remember
- Single channel or nothing. Feed it a 3-channel image and OpenCV asserts (
img.type() == CV_8UC1). Convert withcvtColor(code = 6, BGR→GRAY) or feed it athresholdoutput. - The output isn't a picture. It's a point list. Try to preview it through
Nparrays2Imageand you'll get the pack's classic'NoneType' object has no attribute 'shape'error, which is the pack's way of telling you to check what the OpenCV function really returns. - Batch size 1.
Image2Nparrayrejects anything bigger - drop anImageFromBatchnode withlength = 1in front if you hitbatch_size=2.
Install
Same pack as every node in this family. ComfyUI Manager → search opencv-comfyui → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
requirements.txt installs opencv-contrib-python, numpy, torch. The pack imports cv2 at load time; if that import fails (duplicate or missing OpenCV - the guidedFilter error is the tell), none of its hundreds of nodes register.
If a workflow references _1 and you only see _0, just use _0. They're interchangeable, and that pattern applies to every _0/_1 pair in this pack.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| idxopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |