Nodes/opencv-comfyui/OpenCV estimateTranslation3D_0
ComfyUI Node

OpenCV estimateTranslation3D_0

Pure 3D translation between point sets — the simplest alignment node

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV estimateTranslation3D_0
  • src
  • dst
  • out
  • inliers
  • int
  • nparray_1
  • nparray_2
ransacThreshold
confidence

Of all the geometry nodes in this pack, estimateTranslation3D is the simplest: given two sets of matched 3D points that differ only by a shift - no rotation, no scaling - it finds the translation vector that lines one up with the other. It wraps cv2.estimateTranslation3D from opencv-comfyui (geroldmeisinger/opencv-comfyui), the auto-generated "every OpenCV function as a node" pack. Its twin estimateTranslation3D_1 is byte-identical; grab this one.

The narrow assumption - pure translation only - is both its superpower and its limitation. If your two point sets are actually related by a rotation too, this node will fit badly; that's what estimateAffine3D is for. You'd use estimateTranslation3D when you know the only difference is where the object sits: the same rigid body captured from two positions, or a template point cloud that's just been moved. It uses RANSAC, so a few bad correspondences won't wreck the estimate.

Inputs and outputs

  • src (NPARRAY) - source 3D points, one per row, N×3.
  • dst (NPARRAY) - matching destination 3D points, N×3.
  • ransacThreshold (FLOAT) - inlier tolerance for RANSAC; ~3.0 default, scale it to your point coordinates' units.
  • confidence (FLOAT) - RANSAC confidence, 0.99 default.
  • out (NPARRAY, optional) and inliers (NPARRAY, optional) - OpenCV out-parameters; leave them unconnected (the README says to skip the out-params).
  • Outputs: int - success flag: 1 = fit succeeded, 0 = RANSAC bailed. Check it before trusting anything. nparray_1 - the translation vector (3×1). nparray_2 - the inlier mask (1 = point used in the fit).

Wiring it up

You build the N×3 point arrays yourself and feed them in as nparrays - there's no image path here unless you're converting depth data (e.g. depth maps from a model like Depth Anything) into 3D points first. The outputs are a success flag, a vector, and a mask - none of them displayable images, so don't run them into Nparrays2Image (that's the 'NoneType' object has no attribute 'shape' trap). For 3D alignment work, estimateAffine3D_2 is the more general sibling that also handles rotation and scale; this node is the focused version.

Install

ComfyUI Manager (search "opencv-comfyui") or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, then restart. Dependencies: opencv-contrib-python, numpy, torch - no model downloads. Pack gotchas apply: batch_size-1 images only, literal-string composites, and the author's "Expect dragons!" warning about the raw auto-generated interface. If you're not doing 3D geometry, this whole family is skippable.

Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
srcNPARRAY
dstNPARRAY
ransacThresholdFLOAT
confidenceFLOAT
outoptNPARRAY
inliersoptNPARRAY

Outputs (3)

NameTypeDescription
intINT
nparray_1NPARRAY
nparray_2NPARRAY