Preserve offline geometry, marking, replay and evaluation pipelines with source manifests and synthetic tests. Research qualification does not activate these methods as production navigation.
45 lines
2.9 KiB
Python
45 lines
2.9 KiB
Python
"""Carry existing observations to preplanned support views, without inference.
|
|
|
|
Vehicle exclusion is the maximum across covering source views; unknown is
|
|
blocked. This is the same conservative transfer used by the former coverage
|
|
renderer, now attached to the fixed initial acquisition instead of a rescue.
|
|
"""
|
|
from pathlib import Path
|
|
import json
|
|
import numpy as np,cv2
|
|
from fit_scene import world,project
|
|
|
|
def carry(survey,evidence,layers,run_root):
|
|
manifest_path=Path(run_root)/'observation-coverage.json'
|
|
if not manifest_path.exists():return
|
|
manifest=json.loads(manifest_path.read_text())
|
|
if not manifest['complete']:raise ValueError('Coverage acquisition incomplete')
|
|
originals=[t for t in json.loads((survey/'tile-index.json').read_text())['tiles']if t['status']=='surveyed']
|
|
centers=np.array([np.mean(t['bounds_xy'],axis=0)for t in originals]);records=[]
|
|
for tile in manifest['tiles']:
|
|
name=tile['id'];center=np.mean(tile['bounds_xy'],axis=0)
|
|
with np.load(survey/name/'top.geometry.npz')as z:g=dict(z)
|
|
yy,xx=np.mgrid[:1200,:1200];points=world(np.c_[xx.ravel(),yy.ravel()],g)
|
|
covered=np.zeros(len(points),bool);normal={};ground={};paint={};sources=[]
|
|
for i,source in enumerate(originals):
|
|
if abs(centers[i]-center).max()>65:continue
|
|
sid=source['id']
|
|
with np.load(survey/sid/'top.geometry.npz')as z:sg=dict(z)
|
|
uv=project(points,sg).astype('float32');valid=(uv.min(1)>=0)&(uv.max(1)<1199)
|
|
ids=np.flatnonzero(valid)
|
|
if not len(ids):continue
|
|
sources.append(sid);covered[ids]=True
|
|
for path,target in [(evidence/(sid+'.normal.npz'),normal),(evidence/(sid+'.ground.npz'),ground),(layers/(sid+'.npz'),paint)]:
|
|
with np.load(path)as data:
|
|
for key in data.files:
|
|
plane=target.setdefault(key,np.zeros(len(points),np.float32));a=data[key].astype('float32')
|
|
vals=np.concatenate([cv2.remap(a,b[:,0,None],b[:,1,None],cv2.INTER_LINEAR).ravel()for b in np.array_split(uv[ids],max(1,int(np.ceil(len(ids)/20000))))])
|
|
plane[ids]=np.maximum(plane[ids],vals)
|
|
if not normal:raise ValueError('Support view has no existing semantic observation')
|
|
normal['vehicle'][~covered]=1.;ground['vehicle'][~covered]=1.
|
|
for target,path in [(normal,evidence/(name+'.normal.npz')),(ground,evidence/(name+'.ground.npz')),(paint,layers/(name+'.npz'))]:
|
|
np.savez_compressed(path,**{k:v.reshape(1200,1200).astype('float16')for k,v in target.items()})
|
|
records.append(dict(tile=name,source_tiles=sources,unknown_pixels=int((~covered).sum())))
|
|
(Path(run_root)/'coverage-semantics.json').write_text(json.dumps(dict(inference_calls=0,
|
|
policy='maximum existing observations; unknown vehicle footprint blocked',records=records),indent=2))
|