Nodes/comfyui_cv/CV Depth to 3D Points
ComfyUI Node

CV Depth to 3D Points

Back-projects a depth map to a colored 3-D point cloud using camera intrinsics. For each pixel (u, v) with depth Z, computes X = (u - cx) * Z / fx, Y = (v - cy) * Z / fy. Unlike cv2.reprojectImageTo3D (which is for stereo disparity), this handles monocular depth directly. Feed the depth as a float32 NPARRAY (in any unit — the depth_scale converts to your desired output unit). Output is Nx3 points + Nx3 colors for 'Write PLY'.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Depth to 3D Points
  • depth
  • camera_matrix
  • colors
  • points
  • colors
depth_scale1.000
Categoryimage/CV/low-level

Inputs (4)

NameTypeDefaultDescription
depthNPARRAYHxW float32 depth map. Values can be in any unit (mm, meters, raw model output) — use depth_scale to convert. Single-channel; if loaded via Image->CV (GRAY float32), the channel is already extracted.
camera_matrixNPARRAY3x3 camera intrinsic matrix K from Calibrate Camera (Chessboard) or CV Camera Matrix. fx=K[0,0], fy=K[1,1], cx=K[0,2], cy=K[1,2].
depth_scaleFLOAT1.000Multiplier to convert depth values to meters. E.g. 0.001 if depth is in mm, 1.0 if already in meters, 65535/1000=65.535 for NYU Depth V2 (uint16 mm loaded as float32 0-1).
colorsoptNPARRAYHxWx3 or HxW uint8/float RGB color image (same dimensions as depth). If disconnected, all points are white.

Outputs (2)

NameTypeDescription
pointsNPARRAYNx3 float32 array of 3-D positions.
colorsNPARRAYNx3 uint8 array of per-vertex RGB colors.