Preserve offline geometry, marking, replay and evaluation pipelines with source manifests and synthetic tests. Research qualification does not activate these methods as production navigation.
33 lines
1.9 KiB
Python
33 lines
1.9 KiB
Python
"""Create reproducible spatial cameras from original scanner poses."""
|
|
import time
|
|
import numpy as np
|
|
from scipy.spatial import cKDTree
|
|
from ortho_terrain import sample
|
|
from mv_math import voxel_stations, station_views
|
|
from mv_io import RUN, ORTHO, SCENE, config, read, write, digest, record
|
|
|
|
start = time.monotonic()
|
|
cfg = config()
|
|
pose_path = ORTHO / cfg['scenes'][SCENE]['trajectory']
|
|
poses = np.asarray([p['T'] for p in read(pose_path)['poses']], np.float64)
|
|
field = dict(np.load(ORTHO / 'terrain-reference.npz'))
|
|
height_report = read(ORTHO / 'terrain-report.json')
|
|
assert height_report['used'] and height_report['coordinate_transform'].startswith('identity')
|
|
ground = sample(field, poses[:, :2])
|
|
sensor_height = height_report['sensor_ground_offset_m']
|
|
valid = np.isfinite(poses).all(1) & (abs(poses[:, 2] - ground - sensor_height) < 1.0)
|
|
stations = voxel_stations(poses[valid], cfg['method']['station_spacing_m'])
|
|
if not 10 <= len(stations) <= 600:
|
|
raise ValueError('Station count outside bounded qualification envelope')
|
|
views = station_views(stations, sample(field, stations[:, :2]))
|
|
nearest = cKDTree(stations[:, :2]).query(poses[valid, :2])[0]
|
|
plan = dict(schema='missioncore.multiview-cameras/v1', scene=SCENE,
|
|
pose_sha256=digest(pose_path), terrain_sha256=digest(ORTHO / 'terrain-reference.npz'),
|
|
input_poses=len(poses), rejected_height_poses=int((~valid).sum()),
|
|
stations=views, station_count=len(views), view_count=4 * len(views),
|
|
scan_to_camera_distance_m=dict(median=float(np.median(nearest)), p95=float(np.quantile(nearest,.95)), maximum=float(nearest.max())),
|
|
method=cfg['method'], coordinate_system='scene-local native LCC XYZ, Z up, metres',
|
|
manual_rois=[], seconds=time.monotonic() - start)
|
|
write(RUN / 'cameras.json', plan)
|
|
record({k: v for k, v in plan.items() if k not in ['stations', 'method']})
|