depthpro-wrapper / examples /quickstart.py
bdck's picture
Upload examples/quickstart.py
7efe48b verified
"""
Quick-start: single image → metric depth → point cloud in 10 lines.
"""
from pathlib import Path
from depthpro_wrapper import (
DepthProEstimator,
rgbd_to_point_cloud,
save_point_cloud,
)
# 1. Load estimator (downloads ~2 GB weights on first run)
estimator = DepthProEstimator(device="cuda:0")
# 2. Estimate depth
result = estimator.estimate("photo.jpg")
print(f"Focal length: {result.focal_length:.1f} px")
print(f"Depth range: {result.depth.min():.2f}{result.depth.max():.2f} m")
# 3. Back-project to coloured point cloud
points, colors = rgbd_to_point_cloud(
result.depth,
result.image,
result.focal_length,
)
# 4. Save
save_point_cloud("output.ply", points, colors=colors)
print(f"Saved {len(points):,} points to output.ply")