File size: 772 Bytes
7efe48b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
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")