Nodes/opencv-comfyui/OpenCV triangulatePoints_0
ComfyUI Node

OpenCV triangulatePoints_0

From two cameras to a point cloud, inside a ComfyUI graph

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV triangulatePoints_0
  • projMatr1
  • projMatr2
  • projPoints1
  • projPoints2
  • points4D
  • nparray

This is where the opencv-comfyui pack stops being a filter collection and starts being computer vision. triangulatePoints is the classic stereo-reconstruction routine: you have the same physical point seen from two camera views, you know where both cameras were and how they were oriented, and this node works out the point's 3D position by intersecting the two viewing rays. Feed it a handful of matching points across a stereo pair and it returns their positions in space - that's the raw material of structure-from-motion, photogrammetry, and any 3D-from-2D pipeline.

Be honest about the audience for this one. It's not a node you drag in for a nice image; it's a node you use when you're building something that computes, and in ComfyUI terms that's a rare and specialized workflow. You'd pair it with this pack's calibration nodes (undistort, undistortPoints, findFundamentalMat and friends) to correct the images first, match features across the two views, and only then triangulate. The depth-estimation KB essay is about learned depth - this is the classical, calibration-driven alternative, and it's worth knowing both exist.

Inputs and outputs that matter

  • projMatr1, projMatr2 (NPARRAY) - the 3×4 camera projection matrices for view one and view two. These encode each camera's intrinsics plus its position and rotation in world space.
  • projPoints1, projPoints2 (NPARRAY) - the matched 2D points in each image, as 2×N or N×2 arrays. Every column is one correspondence.

The optional points4D is an out-parameter - the README's universal advice is to leave those unwired. The output is a single nparray: a 4×N array of homogeneous coordinates, one per matched point. You divide each column by its fourth component to get the ordinary (X, Y, Z) world position.

Installation

Pack-wide: ComfyUI Manager (search "OpenCV" or geroldmeisinger/opencv-comfyui), or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, then restart. Needs opencv-contrib-python (pip install opencv-contrib-python). No models - the "camera calibration" is data you bring, not something it downloads.

Common issues

This node lives on the sharp end of the pack's rough edges. Every input is an array, and the shapes have to be right - a 2×N vs N×2 mismatch, or projection matrices that aren't 3×4, will produce OpenCV assertion errors or, worse, plausible-looking wrong 3D points. Bad correspondences (a point matched to the wrong point in the other view) give geometrically impossible results. And remember the conversion choreography: Image2Nparray for images (batch size 1 only), and the numeric arrays you build for points and matrices are NPARRAYs you'll have to assemble elsewhere - this pack gives you the raw function, not the convenience wrappers.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
projMatr1NPARRAY
projMatr2NPARRAY
projPoints1NPARRAY
projPoints2NPARRAY
points4DoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY