Nodes/ComfyUI-Depth-Pro/Focal MM to PX
ComfyUI Node

Focal MM to PX

Tell Depth Pro what lens you shot with

By spacepxl·Created 2 years ago·Updated 2 years ago· 209
Focal MM to PX
    • focal_px
    • focal_str
    focal_mm50.00
    sensor_mm24.576
    image_width1024
    image_height1

    This is the mirror image of Focal PX to MM. Where that node turns Depth Pro's pixel-focal estimate into millimeters for your 3D software, this one goes the other way: you give it a lens focal length in millimeters and it hands you the same focal in pixels, ready to feed back into the Depth Pro node's focal_px override.

    Why would you do that? Two reasons. First, when you actually know the lens - say the reference image is tagged as shot on a 50mm equivalent - you can force Depth Pro to use that instead of its own estimate. The source is explicit that a provided focal replaces the estimated value and rescales the metric depth to match, which is how you get scale-consistent depth across a sequence of frames. Second, if you built a virtual camera in Blender with a specific millimeter lens, converting it to pixels is how you make the depth generation agree with that camera.

    Inputs

    • focal_mm (FLOAT, default 50) - your lens focal in millimeters. 50mm equivalent is a sensible starting point for a "normal" look.
    • sensor_mm (FLOAT, default 24.576) - sensor width in millimeters, same default as the sibling conversion nodes.
    • image_width / image_height (INT) - used to find the long edge of the image, which stands in for the sensor's width in pixels.

    The math is the README's formula run backwards: focal_px = focal_mm * sensor_px / sensor_mm. Outputs are focal_px (FLOAT) and focal_str (STRING), the same value formatted to two decimals.

    The one gotcha

    Remember how Depth Pro treats a focal_px of 1 or less as "no override" and falls back to its own estimate? Real lenses rarely produce pixel focals under 1, so this isn't usually a problem - but if you're working with tiny images, check your converted number. A 1000-pixel-wide image with a 50mm lens and full-frame sensor comes out around 2034 px, so you're safely in override territory. If you see a result below 1, the number is telling you the image is too small for the override to take effect, and the model will silently ignore it.

    Install

    Same as the rest of the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/spacepxl/ComfyUI-Depth-Pro
    

    or install ComfyUI-Depth-Pro via ComfyUI Manager and restart. No extra model download for this node itself - the depth model comes on first run of Depth Pro's load node.

    CategoryDepth-Pro

    Inputs (4)

    NameTypeDefaultDescription
    focal_mmFLOAT50.00
    sensor_mmFLOAT24.576
    image_widthINT1024
    image_heightINT1

    Outputs (2)

    NameTypeDescription
    focal_pxFLOAT
    focal_strSTRING