Nodes/opencv-comfyui/OpenCV polarToCart_1
ComfyUI Node

OpenCV polarToCart_1

PolarToCart_1 — the honest truth about this node and when it earns its place

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV polarToCart_1
  • magnitude
  • angle
  • x
  • y
  • nparray_0
  • nparray_1
angleInDegrees

Let's get the boring part out of the way: polarToCart_1 is the second auto-generated overload of cv2.polarToCart, and it behaves exactly like polarToCart_0. Same inputs, same outputs, same math. The _1 exists because OpenCV's type stubs declare the function more than once, and opencv-comfyui generates a node per declaration rather than merging them. You lose nothing by choosing either.

What it does: converts polar coordinates to Cartesian, per pixel. Feed it a magnitude array and an angle array plus an angleInDegrees boolean, and it computes x = magnitude·cos(angle) and y = magnitude·sin(angle) across both arrays. Out come nparray_0 (x) and nparray_1 (y).

The part nobody tells you

Here's the honest framing, and it applies to both twins: this node is almost never the first thing you need. It sits at the end of a chain - after you've computed optical flow, after you've converted vectors to magnitude/angle, after you've done something with them. It's the "convert back to displacement fields" step in flow-based warping pipelines, the counterpart to cartToPolar. If your workflow doesn't speak in polar form, polarToCart_1 is a solution looking for a problem.

That's not a dig at the pack - it's the nature of auto-generating every OpenCV function. The author said as much when he released it: these nodes are for "small and quick transformations... not full-blown OpenCV apps within Comfy." He's right, and polarToCart_1 is squarely in the "you'll know when you need it" bucket.

What to actually watch for

  • angleInDegrees must match your angle source, or every vector comes out rotated. Radians if False (the default in OpenCV), degrees if True.
  • magnitude and angle must be same-sized float arrays. uint8 input gets rejected by the underlying function.
  • The optional x and y inputs are OpenCV out-parameters - leave them unconnected, per the README's standing advice.
  • The outputs are component arrays, not images. Feed them into Nparrays2Image naively and you'll get either a gray mess or the pack's classic "NoneType object has no attribute shape" error, which the README explains as "not every return type of nparray is actually an image."

Install

Same recipe as every node in this pack - ComfyUI Manager, search "opencv-comfyui", or:

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

restart ComfyUI, then:

pip install opencv-contrib-python

Work through Image2Nparray (batch size 1 only; an ImageFromBatch with length 1 fixes the batch error). Remember the Image2Nparray step flips RGB→BGR and scales to 0..255, so your arrays are in OpenCV's world, which is exactly where a polar↔Cartesian conversion wants to live.

Verdict: fine node, narrow job. Reach for it when flow math hands you magnitude-and-angle and something downstream wants x-and-y. Until then, file it under "good to know exists."

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
magnitudeNPARRAY
angleNPARRAY
angleInDegreesBOOLEAN
xoptNPARRAY
yoptNPARRAY

Outputs (2)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY