OpenCV compare_1
Compare_0's identical twin — and the reason both exist
- src1
- src2
- dst
- nparray
Quick answer: compare_1 does exactly what compare_0 does. Same inputs, same mask output, same OpenCV call. I checked the source - the two class bodies are byte-for-byte identical apart from the name. If you've read the compare_0 page, you already know this node.
The reason both exist is in how the pack is built. opencv-comfyui auto-generates a node for every overload in OpenCV's Python type stubs, and cv2.compare is declared with multiple signatures in the .pyi file. The generator numbered them (_0, _1, …) and shipped them all. Sometimes overloads differ in real ways; here they don't. So you've got a genuine duplicate in your node menu.
What it does (the short version)
Per-element comparison of two arrays:
- src1 / src2 (NPARRAY) - same size, same type.
- cmpop (INT) -
0equal,1>,2>=,3<,4<=,5not equal. - dst (NPARRAY, optional) - an out-parameter; the README tells you to skip the optional out-params, and it's right.
Output: a single nparray - 8-bit single-channel mask, 255 where the comparison is true, 0 where false. Same-size requirement applies or OpenCV throws a shape assertion.
What to do about the duplicate
Pick compare_0 and ignore compare_1, or pick this one and ignore the other - it genuinely doesn't matter. They share the same image/OpenCV category and the same behavior. What does matter is remembering that this is an nparray node: convert your Comfy image with Image2Nparray first (batch size 1 only - split batches with ImageFromBatch), and convert results back with Nparrays2Image.
Install and gotchas
Install once via ComfyUI Manager (search "opencv-comfyui") or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
Requires opencv-python-contrib (pack's requirements.txt lists opencv-contrib-python, numpy, torch). Known conflict in the wild: Cannot import name 'guidedFilter' from 'cv2.ximgproc', which means you have two conflicting OpenCV installs fighting - clean up to one. If your inputs aren't the same size you'll hit (-209:Sizes of input arguments do not match), so resize before comparing. That's the whole troubleshooting list, because the whole node is one function call.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| src1 | NPARRAY | — | |
| src2 | NPARRAY | — | |
| cmpop | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |