feat(research): preserve urban geometry pipelines and qualification suites

Preserve offline geometry, marking, replay and evaluation pipelines with source manifests and synthetic tests. Research qualification does not activate these methods as production navigation.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-29 09:10:00 +03:00
parent 5d56237124
commit 69dc566665
611 changed files with 52016 additions and 28 deletions
@@ -0,0 +1,38 @@
"""Read-only decomposition of existing surface gates. No inference mutations."""
import cv2
import numpy as np
import shapely
from ground_observations import read,POLICY
from fit_scene import project
from row_evidence import choose_owners
def surface_audit(obs,grid,q):
points=grid['points'];inside=shapely.contains_xy(q,points[:,0],points[:,1]);pts=points[inside]
distances=np.linalg.norm(pts[:,None]-obs.centers[None],axis=2)
covered=np.zeros(distances.shape,bool)
for i,t in enumerate(obs.tiles):
uv=project(pts,obs.camera(t['id']));covered[:,i]=(uv.min(1)>=20)&(uv.max(1)<1180)
owners=choose_owners(distances,covered);records=[]
for rank in range(2):
for i in np.unique(owners[:,rank]):
if i<0:continue
xy=pts[owners[:,rank]==i];name=obs.tiles[i]['id']
c=obs.geometry(name);g=obs.geometry(name,True);uv=project(xy,obs.camera(name))
if obs.native:uv=(uv+.5)*c['depth'].shape[0]/1200-.5
a,b=c['depth'],g['depth'];finite=np.isfinite(a)&np.isfinite(b)&(a>0)&(b>0)
safe=np.where(finite,b,0).astype('float32');ratio=b.shape[0]/int(g.get('compatibility_resolution',b.shape[0]))
width=2*int(np.ceil((POLICY['local_window_px']-1)/2*ratio))+1;kernel=np.ones((width,width),'uint8')
neighborhood=cv2.erode(finite.astype('uint8'),kernel)>0
span=cv2.dilate(safe,kernel)-cv2.erode(safe,kernel)
scalar=lambda array:read(array.astype('float32'),uv).ravel()
span_at=read(span,uv,nearest=True).ravel();neighbor_at=read(neighborhood.astype('uint8'),uv,nearest=True).ravel()>0
ca,ga=scalar(c['alpha']),scalar(g['alpha']);gap=np.abs(scalar(a)-scalar(b))
rejected=dict(depth_span=span_at>POLICY['local_depth_span_m'],nonfinite_neighbourhood=~neighbor_at,
context_opacity=ca<POLICY['alpha_min'],ground_opacity=ga<POLICY['alpha_min'],context_ground_gap=gap>POLICY['depth_agreement_m'])
bad=np.logical_or.reduce(list(rejected.values()))
records.append(dict(rank=rank,tile=name,pixels=len(xy),invalid=int(bad.sum()),
reasons={k:int(v.sum()) for k,v in rejected.items()},span_quantiles=np.quantile(span_at,[0,.5,.9,.97,1]).tolist(),
failed_samples=[dict(xy=p.tolist(),span=float(s),context_alpha=float(ac),ground_alpha=float(ag),gap=float(d))
for p,s,ac,ag,d in zip(xy[bad],span_at[bad],ca[bad],ga[bad],gap[bad])]))
return records