@@ -45,52 +45,59 @@ def _update_buffer(self, frames: list[FrameBoxMatch]) -> ClearBuffer:
4545 for i in range (1 , num_frame ):
4646 current_frame = frames [i ]
4747 previous_frame = frames [i - 1 ]
48+ self ._update_buffer_frame (current_frame , previous_frame , buffer )
49+ return buffer
4850
49- buffer .num_gt += current_frame .num_gt
50- for current_match in current_frame .matches :
51- is_id_switch = False
52- is_same_match = False
53- for previous_match in previous_frame .matches :
54- if not previous_match .is_tp (
55- self .scorer ,
56- self .threshold ,
57- previous_frame .ego2map ,
58- ):
59- continue
60-
61- is_id_switch = self ._is_id_switched (current_match , previous_match )
62- if is_id_switch :
63- break
64-
65- is_same_match = self ._is_same_match ()
66- if is_same_match :
67- buffer .num_tp += current_match .is_tp (
68- scorer = self .scorer ,
69- threshold = self .threshold ,
70- ego2map = current_frame .ego2map ,
71- )
72- buffer .score += self .scorer (
73- previous_match .estimation ,
74- previous_match .ground_truth ,
75- ego2map = previous_frame .ego2map ,
76- )
77- break
78-
79- if is_same_match :
51+ def _update_buffer_frame (
52+ self ,
53+ current_frame : FrameBoxMatch ,
54+ previous_frame : FrameBoxMatch ,
55+ buffer : ClearBuffer ,
56+ ) -> None :
57+ buffer .num_gt += current_frame .num_gt
58+ for current_match in current_frame .matches :
59+ is_id_switch = False
60+ is_same_match = False
61+ for previous_match in previous_frame .matches :
62+ if not previous_match .is_tp (
63+ self .scorer ,
64+ self .threshold ,
65+ previous_frame .ego2map ,
66+ ):
8067 continue
8168
82- if current_match .is_tp (self .scorer , self .threshold , current_frame .ego2map ):
83- buffer .num_tp += 1
69+ is_id_switch = self ._is_id_switched (current_match , previous_match )
70+ if is_id_switch :
71+ break
72+
73+ is_same_match = self ._is_same_match (current_match , previous_match )
74+ if is_same_match :
75+ buffer .num_tp += current_match .is_tp (
76+ scorer = self .scorer ,
77+ threshold = self .threshold ,
78+ ego2map = current_frame .ego2map ,
79+ )
8480 buffer .score += self .scorer (
85- current_match .estimation ,
86- current_match .ground_truth ,
87- current_frame .ego2map ,
81+ previous_match .estimation ,
82+ previous_match .ground_truth ,
83+ ego2map = previous_frame .ego2map ,
8884 )
89- if is_id_switch :
90- buffer .num_id_switch += 1
91- else :
92- buffer .num_fp += 1
93- return buffer
85+ break
86+
87+ if is_same_match :
88+ continue
89+
90+ if current_match .is_tp (self .scorer , self .threshold , current_frame .ego2map ):
91+ buffer .num_tp += 1
92+ buffer .score += self .scorer (
93+ current_match .estimation ,
94+ current_match .ground_truth ,
95+ current_frame .ego2map ,
96+ )
97+ if is_id_switch :
98+ buffer .num_id_switch += 1
99+ else :
100+ buffer .num_fp += 1
94101
95102 def _is_id_switched (self , current_match : BoxMatch , previous_match : BoxMatch ) -> bool :
96103 if (not current_match .is_matched ()) and (not previous_match .is_matched ()):
0 commit comments