Preserve offline geometry, marking, replay and evaluation pipelines with source manifests and synthetic tests. Research qualification does not activate these methods as production navigation.
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
"""Original-pixel area overlap for search and independent XY admission.
|
|
|
|
A pixel represents a cell, not a point. Exact cell intersections avoid the
|
|
pose-dependent step function of classifying pixel centres inside a polygon.
|
|
The .65 IoU gate is retained. Boundary and diagnostic corner metrics are kept.
|
|
"""
|
|
import numpy as np
|
|
from pixel_geometry import vector
|
|
from standard_arrow_evidence import metrics as legacy_metrics
|
|
|
|
|
|
def fields(grid,view):
|
|
h,w=grid['size'];cell=grid['cell'];lo=grid['lo']
|
|
patch=dict(width_px=w,height_px=h,world_corners=np.array([lo,lo+[w*cell,0],lo+[w*cell,h*cell],lo+[0,h*cell]]))
|
|
known=view['allowed']&view['observed']
|
|
return dict(known=vector(known,patch),paint=vector(view['target']&known,patch))
|
|
|
|
|
|
def area_iou(q,field):
|
|
measured=q.intersection(field['known']);paint=field['paint']
|
|
intersection=measured.intersection(paint).area
|
|
return intersection/max(measured.area+paint.area-intersection,1e-12)
|
|
|
|
|
|
def metrics(q,grid,view):
|
|
result=legacy_metrics(q,grid,view)
|
|
result['iou']=area_iou(q,fields(grid,view))
|
|
return result
|