Nodes/opencv-comfyui/OpenCV accumulateProduct_0
ComfyUI Node

OpenCV accumulateProduct_0

OpenCV accumulateProduct_0

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV accumulateProduct_0
  • src1
  • src2
  • dst
  • mask
  • nparray

accumulateProduct_0 wraps cv2.accumulateProduct(src1, src2, dst[, mask]), which computes dst = dst + src1 * src2. It's the "running sum of products" node: instead of adding a frame into an accumulator like accumulate_0 does, it multiplies two inputs pixel by pixel and adds that into the running total.

That's a niche operation in a ComfyUI context, so let me be straight with you: you will rarely reach for this in an image pipeline. Its real home is signal processing and computer-vision statistics - accumulating cross-correlation terms, computing covariance-ish sums over image pairs, or any loop where you need Σ(a·b) built up frame by frame. If you know you need a running sum of products, this is precisely it; if you don't, you almost certainly don't need this node.

How it works

Same accumulator pattern as the rest of the family: dst is both an input and the output, mutated in place. src1 and src2 are the images to multiply, dst is the accumulator you're growing, and the optional mask limits which pixels participate. The critical constraint carries over from accumulate_0: OpenCV wants dst to be a floating-point array of the same size as the inputs, so a uint8 array straight out of Image2Nparray will fail with a dst.type() == CV_32F assertion.

The inputs that matter

  • src1 / src2 (NPARRAY) - the two images to multiply together, element-wise.
  • dst (NPARRAY, required) - the accumulator. Float32, same size as src1/src2, usually zeros to start.
  • mask (NPARRAY, optional) - restrict the accumulation to nonzero mask pixels.

Output is a single nparray - the updated running sum of products.

Where it sits

Honestly? On the shelf, unless your workflow is doing math over a sequence of frames. opencv-comfyui auto-generates a node for every top-level cv2 function that survives its type filter - 635 of them - and this one is closer to "exhaustive API coverage" than "everyday tool". The README is upfront that not every generated function is useful inside ComfyUI, and accumulateProduct is a fair example. That's fine: when you do need Σ(a·b), you'd rather have the wrapper than write Python.

Installing opencv-comfyui

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

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

Restart ComfyUI. Dependency: opencv-contrib-python (you probably already have it).

Gotchas

  • Float accumulator required - dst must be float32, same size as the inputs.
  • Batch_size == 1 - Image2Nparray won't take batches; use ImageFromBatch.
  • Not an image output - the accumulator nparray is a float array, not a display-ready image. Expect Nparrays2Image to need real image-shaped input; that's the pack's own documented failure mode.
Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
src1NPARRAY
src2NPARRAY
dstNPARRAY
maskoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY