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:
@@ -0,0 +1,52 @@
|
||||
"""Bounded local strip proposals from opposite edges of connected paint.
|
||||
|
||||
The binary foreground is supplied by the existing primary detector. No colour,
|
||||
visibility, road or final-admission threshold is changed. A connected parking
|
||||
shape can contain several thin bodies; its whole bounding box is not a body.
|
||||
"""
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
|
||||
def branches(contour,binary,mpp):
|
||||
boundary=cv2.approxPolyDP(contour,.025/mpp,True)[:,0].astype(float)
|
||||
if len(boundary)<=4:return []
|
||||
starts=boundary;ends=np.roll(boundary,-1,axis=0);vectors=ends-starts
|
||||
lengths=np.linalg.norm(vectors,axis=1);keep=lengths*mpp>.26
|
||||
starts,ends,lengths,vectors=starts[keep],ends[keep],lengths[keep],vectors[keep]
|
||||
if len(starts)<2:return []
|
||||
axes=vectors/lengths[:,None];candidates=[]
|
||||
# Each contour edge may support at most one opposite-side interpretation.
|
||||
# This bounds alternatives by observed boundary complexity, not a grid of
|
||||
# guessed angles/widths/positions or a list of previously missed objects.
|
||||
for i,(a,b,u)in enumerate(zip(starts,ends,axes)):
|
||||
n=np.array([-u[1],u[0]]);best=None
|
||||
alignment=axes@u
|
||||
for j in np.flatnonzero(alignment<-np.cos(np.deg2rad(8))):
|
||||
if j==i:continue
|
||||
q=np.array([starts[j],ends[j]])-a;t=q@u;offset=q@n
|
||||
width=abs(float(np.mean(offset)))
|
||||
if not .045<width*mpp<.45:continue
|
||||
if np.ptp(offset)*mpp>.045:continue
|
||||
lo=max(0.,float(t.min()));hi=min(lengths[i],float(t.max()))
|
||||
length=(hi-lo)*mpp
|
||||
if not .26<length<65 or length/(width*mpp)<=2.:continue
|
||||
center=(lo+hi)/2*u+a+np.mean(offset)/2*n
|
||||
half_u=(hi-lo)/2*u;half_n=width/2*n
|
||||
box=np.array([center-half_u-half_n,center+half_u-half_n,center+half_u+half_n,center-half_u+half_n])
|
||||
# Same .48 foreground occupancy gate as the original component
|
||||
# proposal, evaluated on this measured body, not on its parent.
|
||||
low=np.floor(box.min(0)).astype(int);high=np.ceil(box.max(0)).astype(int)+1
|
||||
low=np.maximum(low,0);high=np.minimum(high,[binary.shape[1],binary.shape[0]])
|
||||
if np.any(high<=low):continue
|
||||
mask=np.zeros((high[1]-low[1],high[0]-low[0]),np.uint8)
|
||||
cv2.fillConvexPoly(mask,np.rint(box-low).astype('int32'),1)
|
||||
fill=float(binary[low[1]:high[1],low[0]:high[0]][mask>0].mean())
|
||||
if fill<=.48:continue
|
||||
score=(length,fill,-width,-int(j))
|
||||
if best is None or score>best[0]:best=(score,box,tuple(sorted((i,int(j)))))
|
||||
if best is not None:candidates.append(best)
|
||||
unique={pair:(score,box)for score,box,pair in candidates}
|
||||
return [unique[pair][1]for pair in sorted(unique)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user