OpenCV HuMoments_1
The duplicate shape-fingerprint node — same seven numbers
- hu
- nparray
HuMoments_1 is the second overload of cv2.HuMoments and it behaves identically to HuMoments_0 - same STRING m input, same 7×1 nparray output, same function call. The opencv-comfyui generator duplicates overloads across the pack, and this is one of the duplicates. Pick whichever shows up in your search.
What it does
Computes the seven Hu moments of a shape: rotation-, scale-, and translation-invariant descriptors used for shape matching. Read the HuMoments_0 article for the full story - everything there applies, including the wiring quirk.
That quirk matters, so repeat it here: m is a STRING input, because the pack passes the Moments object around as a Python literal string that gets ast.literal_eval()'d. You can't type one by hand. The intended chain is the pack's moments_0 node (which outputs the raw moments as a STRING "literal") into this m input. The optional hu input is the generator's out-parameter - leave it disconnected and take the nparray output.
Realistic use
Shape classification: turn a mask into a silhouette, get the 7-vector, compare against known shapes. It's niche even inside computer vision, and in ComfyUI you'll be doing the comparing with your own math nodes. Don't reach for it for anything day-to-day.
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.
Bottom line
_0 vs _1 is a non-decision - same function. The real friction is the string-literal Moments wiring and getting a clean silhouette upstream. If you're here for shape matching, budget time for those two, not for choosing between copies of the node.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| m | STRING | — | |
| huopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |