Nodes/opencv-comfyui/OpenCV sumElems_1
ComfyUI Node

OpenCV sumElems_1

SumElems_1 — the duplicate that returns a string scalar

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV sumElems_1
  • src
  • literal

sumElems_1 is sumElems_0 wearing a different suffix - same generated wrapper, same cv2.sumElems call, same single input and same string output. The pack auto-generates a node per OpenCV overload and doesn't dedupe, so you get twins. No difference. Pick one and get on with your life.

So what is it? It sums every pixel in every channel of an NPARRAY and returns the total as a string - a per-channel Scalar, e.g. (1.2e7, 1.1e7, 9.8e6, 0.0), because the output type here is STRING, not an image. It's a raw stats function that the generator wrapped because it's top-level in cv2, and it's the pack's most honest demonstration of why the README says "Expect dragons!".

Where you'd actually use it: a quick mean-brightness probe (sum ÷ pixel count), a sanity check that an upstream node isn't handing you an all-zero array, or a crude frame-to-frame energy metric. It's a debugging instrument more than a pipeline stage. And it's the textbook source of the pack's most confusing error: feed this output into Nparrays2Image and you'll get 'NoneType' object has no attribute 'shape', because the value isn't an image or even an nparray - it's a string. If your goal is a single usable brightness number, prefer mean_0 in this same pack; it returns a scalar you can actually wire into arithmetic. This node is for when you specifically want the four-channel sum and you're fine reading it as text.

The contract. Even this scalar node takes NPARRAY input - BGR uint8 0–255 numpy, not ComfyUI IMAGE. Image2Nparray on the way in (batch_size 1 only).

Install. ComfyUI Manager → search "opencv-comfyui", or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

restart. Requires opencv-contrib-python, numpy, torch; if you see Cannot import name 'guidedFilter' from 'cv2.ximgproc' at startup, resolve the conflicting OpenCV packages before anything else.

Categoryimage/OpenCV

Inputs (1)

NameTypeDefaultDescription
srcNPARRAY

Outputs (1)

NameTypeDescription
literalSTRING