44import numpy as np
55import supervision as sv
66
7- from sports .annotators .soccer import draw_pitch , draw_points_on_pitch , player_ellipse_annotator
7+ from sports .annotators .soccer import draw_pitch , draw_points_on_pitch , draw_goals_on_pitch , player_ellipse_annotator
88from sports .common .draw import draw_text_shadow
99from sports .common .homography import valid_pitch_cm
1010from sports .common .kinematics import (
@@ -305,12 +305,24 @@ def draw_radar_minimap(
305305 margin_x : int = 12 ,
306306 margin_y : int = 12 ,
307307 alpha : float = RADAR_MINIMAP_ALPHA ,
308+ locked_goal_defenders : tuple [int , int ] | None = None ,
308309) -> np .ndarray :
309310 """Overlay a plain translucent radar minimap in the bottom-right corner."""
310311 if transformer is None :
311312 return frame
312313 config = SoccerPitchConfiguration ()
313314 radar = draw_pitch (config = config , padding = padding , scale = minimap_scale )
315+ if locked_goal_defenders is not None :
316+ left_def , right_def = locked_goal_defenders
317+ if left_def in (0 , 1 ) and right_def in (0 , 1 ):
318+ radar = draw_goals_on_pitch (
319+ config ,
320+ left_defender_team = left_def ,
321+ right_defender_team = right_def ,
322+ padding = padding ,
323+ scale = minimap_scale ,
324+ pitch = radar ,
325+ )
314326 pmask = player_mask (detections )
315327 if pmask .any ():
316328 pdet = detections [pmask ]
@@ -422,6 +434,7 @@ def build_trace_minimap(
422434 config = None ,
423435 scale : float = RADAR_MINIMAP_SCALE ,
424436 padding : int = RADAR_MINIMAP_PAD ,
437+ locked_goal_defenders : tuple [int , int ] | None = None ,
425438) -> np .ndarray :
426439 """Build a radar minimap with per-track colored traces and current player dots."""
427440 if focus_tid is not None :
@@ -430,6 +443,17 @@ def build_trace_minimap(
430443 if config is None :
431444 config = SoccerPitchConfiguration ()
432445 radar = draw_pitch (config = config , padding = padding , scale = scale )
446+ if locked_goal_defenders is not None :
447+ left_def , right_def = locked_goal_defenders
448+ if left_def in (0 , 1 ) and right_def in (0 , 1 ):
449+ radar = draw_goals_on_pitch (
450+ config ,
451+ left_defender_team = left_def ,
452+ right_defender_team = right_def ,
453+ padding = padding ,
454+ scale = scale ,
455+ pitch = radar ,
456+ )
433457
434458 if focus_tid is None :
435459 trace_items = trace_by_tid .items ()
0 commit comments