Exemple #1
0
 def post_optim_step(self, optim_motions):
     """ When each time an optimized motion arrive, we have to update the corresponding motion and predicted bbox location
     """
     if len(optim_motions.shape) == 1:
         optim_motions = optim_motions.reshape((-1, 4))
     for i in range(1, self.size):
         self.motion_buffer.set_val(i, optim_motions[i - 1])
         prev_bbox = self.state_buffer.access(i - 1)
         next_bbox = BBox.motion2bbox(prev_bbox, optim_motions[i - 1])
         self.state_buffer.set_val(i, next_bbox)
     return
Exemple #2
0
 def pre_frame_optim(self, pred_motion):
     """ before optimizing each frame, motion model takes in a roughly predicted motion
     Args:
         pred_motion (np.ndarray): a rough prediction for the motion
     """
     # When encountering frame 0
     # push the start_bbox and the dummy pred_motion into the buffer
     if self.size == 0:
         self.state_buffer.push(self.start_state)
         self.motion_buffer.push(pred_motion)
     # At other frames, the predicted motion is right
     else:
         prev_bbox = self.state_buffer.last()
         pred_bbox = BBox.motion2bbox(prev_bbox, pred_motion)
         self.state_buffer.push(pred_bbox)
         self.motion_buffer.push(pred_motion)
     
     self.size = self.state_buffer.size
     return