Preserve offline geometry, marking, replay and evaluation pipelines with source manifests and synthetic tests. Research qualification does not activate these methods as production navigation.
50 lines
2.4 KiB
Python
50 lines
2.4 KiB
Python
"""Whole-arrow context is paved ground, not the presence of parallel stripes.
|
|
|
|
An extracted stem is a replaceable fragment only after whole-symbol evidence.
|
|
Existing non-linear symbols retain priority; arbitrary crossing lines veto the
|
|
transaction through the inherited component_conflicts checks.
|
|
"""
|
|
import shapely
|
|
from shapely.geometry import shape
|
|
from glyph_rules import POLICY as GLYPH_POLICY, accept_symbol
|
|
|
|
VERSION = 'paved-whole-arrow-admission-v7'
|
|
POLICY = {**GLYPH_POLICY, 'arrow_context': 'observed-paved-ground',
|
|
'surface_classes': [1, 2], 'parallel_stripes_required': False, 'arrow_connectivity_open_m': 0.,
|
|
'replacement': 'existing-whole-symbol-conflict-policy',
|
|
'registration_required': True,
|
|
'paint_connectivity_scope': 'whole-observed-paved-component-with-semantic-seed',
|
|
'end_probe_validity': 'observed-symbol-endpoint',
|
|
'end_probe_paint': 'endpoint-connected-paved-paint'}
|
|
|
|
|
|
def already_has_symbol(target, features):
|
|
symbols = [shapely.force_2d(shape(f['geometry'])) for f in features
|
|
if f['properties'].get('class') == 'road_marking'
|
|
and f['properties'].get('subtype') != 'linear_marking']
|
|
covered = shapely.union_all(symbols).buffer(.12).intersection(target).area
|
|
return covered / max(target.area, 1e-9) > .5
|
|
|
|
|
|
def registered_geometry_passes(metrics):
|
|
# Absolute gates apply to new geometry; the inherited registration gain
|
|
# test belongs to replacing an already accepted object, not first admission.
|
|
from registration import POLICY as REGISTRATION_POLICY
|
|
first = metrics[0]
|
|
if first['coverage'] != 1. or first['valid'] < REGISTRATION_POLICY['min_valid']:
|
|
return False
|
|
for rank, m in enumerate(metrics):
|
|
if rank and m['coverage'] < .95:
|
|
continue
|
|
if m['valid']/max(m['coverage'],1e-9) < REGISTRATION_POLICY['min_valid']:
|
|
return False
|
|
if m['iou'] < REGISTRATION_POLICY['min_iou']:
|
|
return False
|
|
if m['boundary_mean_m'] > REGISTRATION_POLICY['max_boundary_mean_m'] or m['boundary_p90_m'] > REGISTRATION_POLICY['max_boundary_p90_m']:
|
|
return False
|
|
if m.get('endpoint_xy_error_m',m['endpoint_error_m']) > REGISTRATION_POLICY['max_endpoint_error_m'] + (.04 if rank else 0.):
|
|
return False
|
|
if m['endpoint_error_m'] > REGISTRATION_POLICY['max_endpoint_error_m'] + (.04 if rank else 0.):
|
|
return False
|
|
return True
|