Nodes/camera-comfyUI/ReprojectDepth
ComfyUI Node

ReprojectDepth

Warping depth maps between projections, with a validity mask thrown in

By Alexankharin·Created about a year ago·Updated about a month ago· 36
ReprojectDepth
  • depth
  • transform_matrix
  • reprojected_depth
  • reprojected_mask
input_horizontal_fov90
output_horizontal_fov90
input_projection
output_projection
output_width0
output_height0
inversefalse

ReprojectImage handles the color; this is its twin for the depth channel. ReprojectDepth takes a depth tensor and remaps it between the pack's three projections (PINHOLE, FISHEYE, EQUIRECTANGULAR), optionally through a 4×4 camera transform, and - the part people actually appreciate - hands you back a mask of which pixels have valid depth in the new view.

Why does that mask matter? Because depth is how this pack lifts images into 3D. When you reproject a depth map into a new projection, the edges of the source view become holes in the target, and if you don't know where those holes are, you'll happily lift garbage geometry into a point cloud. The reprojected_mask output (1.0 = valid) is exactly the coverage signal you need to feed downstream nodes or to composite reprojected depth with something else.

The inputs

  • depth - a depth TENSOR; the node accepts 2D [H,W], 3D, or 4D batch layouts and normalizes them internally.
  • input_projection / output_projection and the two fov fields - same projection language as ReprojectImage. Fov matters just as much here; a wrong fov warps geometry even if the image looked fine.
  • output_width / output_height - 0 (default) keeps the input resolution; set them to match a reprojected color image so the pair lines up pixel-for-pixel.
  • transform_matrix - optional MAT_4X4; rotate or move the camera before sampling.
  • inverse - invert the matrix when your poses use the other convention.

What comes out

  • reprojected_depth - the depth map in the new projection.
  • reprojected_mask - 1.0 where the new view actually has data, 0.0 where it sampled outside the source.

The classic usage is keeping color and depth in lockstep: run the same image through ReprojectImage and the corresponding depth through ReprojectDepth with identical projection/fov/matrix settings, and you end up with an RGB-D pair in the new view that you can hand to DepthToPointCloud.

One caveat to internalize

The pack's docs hammer on the difference between Z-depth and ray depth (radial distance). VideoPoseEstimator and the Depth-Anything metric models output Z-depth; the lifting and reprojection nodes expect ray depth. If geometry bows outward at wide fovs, you skipped the ZDepthToRayDepthNode step. ReprojectDepth itself is just resampling whatever it's given - garbage depth in, garbage depth out - so make sure the source is in the convention your downstream nodes want.

Installing it

Part of camera-comfyUI. Manager → search camera-comfyUI → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Alexankharin/camera-comfyUI.git
cd camera-comfyUI && python install.py

No extra dependencies for this node.

Common issues

  • Depth and color don't line up - almost always mismatched projection, fov, or matrix settings between the ReprojectImage and ReprojectDepth instances. Mirror them exactly.
  • Mask is all zeros at the edges - correct behavior; that's the boundary of your source view.
  • Bow-shaped geometry at wide fov - Z-depth vs ray-depth mismatch upstream. Insert ZDepthToRayDepthNode.
CategoryCamera/Reprojection

Inputs (9)

NameTypeDefaultDescription
depthTENSOR
input_horizontal_fovFLOAT900–360
output_horizontal_fovFLOAT900–360
input_projectionCOMBOinput projection type
output_projectionCOMBOoutput projection type
output_widthINT00–16384
output_heightINT00–16384
transform_matrixMAT_4X4
inverseBOOLEANfalse

Outputs (2)

NameTypeDescription
reprojected_depthTENSOR
reprojected_maskMASK