Using VGGT with DVSA-API:
Pipeline:
Frames
->
VGGT
->
Dense point cloud + camera poses + depth
->
Orthographic renderer
->
mosaic.png
VGGT directly infers camera parameters, depth maps, point maps, and 3D tracks from one or many views. The project also explicitly provides COLMAP-compatible export that can be consumed by Gaussian Splatting or other reconstruction pipelines. Prototype:
"""
Experimental VGGT Orthomosaic Generator
Input:
drone.mp4
Output:
orthomosaic.png
Requirements:
pip install torch torchvision pillow opencv-python
pip install git+https://github.com/facebookresearch/vggt.git
This is an experimental prototype. It renders a top-down orthographic view from VGGT 3D predictions.
"""
import cv2
import numpy as np
import torch
from PIL import Image
from vggt.models.vggt import VGGT
from vggt.utils.load_fn import load_and_preprocess_images
DEVICE = "cuda"
# --------------------------------------------------
# Frame Extraction
# --------------------------------------------------
def sample_frames(video_path,
stride=30,
limit=64):
cap = cv2.VideoCapture(video_path)
frames = []
idx = 0
while True:
ok, frame = cap.read()
if not ok:
break
if idx % stride == 0:
frame = cv2.cvtColor(
frame,
cv2.COLOR_BGR2RGB
)
frames.append(
Image.fromarray(frame)
)
if len(frames) >= limit:
break
idx += 1
cap.release()
return frames
frames = sample_frames(
"drone.mp4",
stride=20,
limit=96
)
# --------------------------------------------------
# Load VGGT
# --------------------------------------------------
model = VGGT.from_pretrained(
"facebook/VGGT-1B"
)
model = model.to(DEVICE)
model.eval()
# --------------------------------------------------
# Preprocess
# --------------------------------------------------
images = load_and_preprocess_images(
frames
)
images = images.to(DEVICE)
# --------------------------------------------------
# Inference
# --------------------------------------------------
with torch.no_grad():
preds = model(images)
# VGGT provides:
#
# point maps
# depth maps
# camera parameters
#
# Names may vary by release.
points3d = preds["points3d"]
# Shape:
# [N, H, W, 3]
points3d = (
points3d
.cpu()
.numpy()
)
# --------------------------------------------------
# Aggregate all views
# --------------------------------------------------
xyz = points3d.reshape(
-1,
3
)
xyz = xyz[
np.isfinite(xyz).all(axis=1)
]
# --------------------------------------------------
# Take top-down projection
# --------------------------------------------------
xmin = xyz[:, 0].min()
xmax = xyz[:, 0].max()
zmin = xyz[:, 2].min()
zmax = xyz[:, 2].max()
canvas_w = 12000
canvas_h = 12000
canvas = np.zeros(
(canvas_h, canvas_w, 3),
dtype=np.uint8
)
# --------------------------------------------------
# Reproject frame colors
# --------------------------------------------------
for view_idx, frame in enumerate(frames):
rgb = np.array(frame)
pts = points3d[view_idx]
h, w = rgb.shape[:2]
pts = pts.reshape(-1, 3)
rgb = rgb.reshape(-1, 3)
valid = np.isfinite(
pts
).all(axis=1)
pts = pts[valid]
colors = rgb[valid]
xs = (
(pts[:, 0] - xmin)
/ (xmax - xmin)
* (canvas_w - 1)
).astype(np.int32)
ys = (
(pts[:, 2] - zmin)
/ (zmax - zmin)
* (canvas_h - 1)
).astype(np.int32)
canvas[
canvas_h - 1 - ys,
xs
] = colors
# --------------------------------------------------
# Save orthomosaic
# --------------------------------------------------
cv2.imwrite(
"orthomosaic.png",
cv2.cvtColor(
canvas,
cv2.COLOR_RGB2BGR
)
)
print(
"saved orthomosaic.png"
)
For DVSA specifically, these four modifications go beyond this prototype:
Adaptive frame sampling, not fixed stride. Keep frames only when visual novelty exceeds a threshold.
Tile the survey into windows of 32-128 frames, run VGGT per window, then merge clouds. VGGT can handle many frames, and newer updates reportedly improved memory efficiency and allow roughly 2-3× more input frames.
Use VGGT → COLMAP export → gsplat, because the project explicitly notes that COLMAP outputs can be fed into Gaussian Splatting pipelines.
Orthographic rendering from splats, not directly from point clouds. That will generally produce a much cleaner image for parks, roads, parking lots, and large urban regions.
This VGGT → point cloud → splat → orthographic render pipeline is designed to infer scene geometry from many views directly, whereas orthomosaic stitching is only an indirect use of image correspondences
@codingexercise: Codingexercise-12-05-2026.docx : https://1drv.ms/w/c/d609fb70e39b65c8/IQDOnx7_qLkoT5Kr3qksqVMMAbRo-PVQsUc_YhwkDrMNoJk?e=d2PQff