OpenCV estimateAffine3D_0
3D point-set alignment in ComfyUI — niche, but here's how it works
- src
- dst
- out
- inliers
- int
- nparray_1
- nparray_2
Take two sets of 3D points - the corners of a detected object and the corners of its 3D model, or two scans of the same surface - and estimateAffine3D finds the 3D rotation, translation, and scale that align them. It's the 3D version of estimateAffine2D, and it returns a 4×4-ish affine transform (3×4 matrix, really) plus an inlier mask from its RANSAC fit. Useful for camera pose estimation, point-cloud registration, and 3D reconstruction pipelines. In ComfyUI terms: this is the deep end. You're only here if you're doing real geometry work, not chasing pretty pictures.
This is the cv2.estimateAffine3D wrapper from opencv-comfyui (geroldmeisinger/opencv-comfyui), the auto-generated "every OpenCV function as a node" pack. The _0 suffix means "first overload," and its twin _1 is functionally identical - pick either. If the 3D math isn't your thing, this family of nodes (plus estimateTranslation3D) is the one part of the pack you can safely skip.
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 the RANSAC stage. Default ~3.0; units are your point coordinate units, so raise it for noisy or badly scaled point sets.
- confidence (FLOAT) - how confident RANSAC must be. 0.99 is the standard default; lowering it speeds things up but trusts fewer iterations.
- out (NPARRAY, optional) and inliers (NPARRAY, optional) - OpenCV out-parameters. Leave them unconnected; the README for this pack says to avoid the out-params.
- Outputs: int - success flag:
1if the fit succeeded,0if RANSAC gave up. Check this before trusting the matrix! nparray_1 - the 3×4 affine transform. nparray_2 - the inlier mask (1 = point used in the fit).
Wiring it up
Realistically: Image2Nparray isn't going to help you here unless your depth data came from images (see the depth-estimation space - e.g. depth maps from Depth Anything can be turned into 3D point sets). You'll be constructing N×3 point arrays yourself and feeding them in as nparrays. The output transform is a plain matrix - you'd apply it to your own point cloud, or chain it into geometry code outside ComfyUI. None of the outputs are displayable images, so don't try to run them through Nparrays2Image (that's the classic 'NoneType' object has no attribute 'shape' trap in this pack).
Install
ComfyUI Manager (search "opencv-comfyui") or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
Restart ComfyUI. Dependencies: opencv-contrib-python, numpy, torch - no model downloads. This pack is auto-generated from OpenCV's type stubs and the author leads with "Expect dragons!": raw enum numbers, string-literal composites, no hand-holding. The _0 and _1 overload twins are byte-identical here, so your only real decision is whether this node belongs in your graph at all. For image-alignment work in 2D, the estimateAffine2D family is the more approachable sibling.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| dst | NPARRAY | — | |
| ransacThreshold | FLOAT | — | |
| confidence | FLOAT | — | |
| outopt | NPARRAY | — | |
| inliersopt | NPARRAY | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| int | INT | — |
| nparray_1 | NPARRAY | — |
| nparray_2 | NPARRAY | — |