class_docstr: Implementation of the SMOT tracker
  The steps to use the tracker is:
  0. Set anchors from the SSD
  1. First call tracker.predict(new_frame)
  2. Then get the tracking anchor information
  3. Run the detractor with the tracking anchor information
  4. Run tracker.update(new_detection, track_info).
class_docstr_tok: ["Implementation","of","the","SMOT","tracker","The","steps","to","use","the","tracker","is",":","0",".","Set","anchors","from","the","SSD","1",".","First","call","tracker.predict","(","new_frame",")","2",".","Then","get","the","tracking","anchor","information","3",".","Run","the","detractor","with","the","tracking","anchor","information","4",".","Run","tracker.update","(","new_detection",",","track_info",")","."]
docstr: Perform motion prediction and assign the predicted track locations to corresponding anchors for re-detection.
  It will update the following properties:
      next_frame_pred_index: indices of anchors that bear tracking information. Each track will be assigned to
          several anchors. They will vote in the re-detection processs.
      next_frame_pred_weights: weights in the re-detection voting
      next_frame_pred_bbox: motion-predicted locations of the tracked objects
      waiting_update_tracks: active tracks for re-detection
      next_frame_ref_bbox: original locations of the tracked objects
  
  Parameters
  ----------
  new_frame: BGR frame of this timestep
  motion_pred_data: extra data needed by the motion predictor
  Returns:
      next_frame_pred_index
      next_frame_pred_weights
  -------
docstr_tok: ["Perform","motion","prediction","and","assign","the","predicted","track","locations","to","corresponding","anchors","for","re-detection",".","It","will","update","the","following","properties",":","next_frame_pred_index",":","indices","of","anchors","that","bear","tracking","information",".","Each","track","will","be","assigned","to","several","anchors",".","They","will","vote","in","the","re-detection","processs",".","next_frame_pred_weights",":","weights","in","the","re-detection","voting","next_frame_pred_bbox",":","motion-predicted","locations","of","the","tracked","objects","waiting_update_tracks",":","active","tracks","for","re-detection","next_frame_ref_bbox",":","original","locations","of","the","tracked","objects","Parameters","--","--","--","--","--","new_frame",":","BGR","frame","of","this","timestep","motion_pred_data",":","extra","data","needed","by","the","motion","predictor","Returns",":","next_frame_pred_index","next_frame_pred_weights","--","--","--","-"]
code: def motion_predict(self, new_frame: np.ndarray, motion_pred_data):
      """
      Perform motion prediction and assign the predicted track locations to corresponding anchors for re-detection.
      It will update the following properties:
          next_frame_pred_index: indices of anchors that bear tracking information. Each track will be assigned to
              several anchors. They will vote in the re-detection processs.
          next_frame_pred_weights: weights in the re-detection voting
          next_frame_pred_bbox: motion-predicted locations of the tracked objects
          waiting_update_tracks: active tracks for re-detection
          next_frame_ref_bbox: original locations of the tracked objects
  
      Parameters
      ----------
      new_frame: BGR frame of this timestep
      motion_pred_data: extra data needed by the motion predictor
      Returns:
          next_frame_pred_index
          next_frame_pred_weights
      -------
  
      """
      # STEP 1: Find all active tracks
      active_track_boxes = []
      active_track_indices = []
      active_track_anchor_indices = []
      active_track_anchor_weights = []
      active_track_classes = []
  
      t_active = time.time()
      for track_idx, track in enumerate(self.tracks):
          if track.is_active():
              active_track_boxes.append(track.mean)
              active_track_indices.append(track_idx)
              src_idx, src_weights = track.source
              active_track_anchor_indices.append(src_idx)
              active_track_anchor_weights.append(src_weights)
              active_track_classes.append([track.class_id])
              logging.debug(
                  "active track {} with age: {}".format(
                      track.track_id, track.age
                  )
              )
      active_track_boxes = np.array(active_track_boxes)
      active_track_anchor_indices = np.array(
          active_track_anchor_indices
      )
      active_track_anchor_weights = np.array(
          active_track_anchor_weights
      )
      e_active = time.time() - t_active
      logging.info("find active runtime: {:.05f}".format(e_active))
  
      if len(active_track_boxes) > 0:
          # The following steps only happen if we have something to track
  
          # STEP 2: Warp the boxes according to flow
          predicted_track_boxes = self._motion_prediction(
              new_frame,
              active_track_boxes,
              active_track_anchor_indices,
              active_track_anchor_weights,
              motion_pred_data,
              skip=not self.use_motion,
          )
  
          # STEP 3: Assign the warped boxes to anchor compositions
          (
              tracking_anchor_indices,
              tracking_anchor_weights,
              tracking_anchor_validity,
          ) = self._assign_box_to_anchors(
              predicted_track_boxes,
              method=self.anchor_assignment_method,
          )
  
          # remove tracks becoming invalid after motion prediction
          invalid_track_numbers = np.nonzero(
              1 - tracking_anchor_validity
          )[0]
          logging.info(
              "{}/{} tracks become invalid after motion prediction".format(
                  len(invalid_track_numbers), len(active_track_boxes)
              )
          )
  
          for i_invalid in invalid_track_numbers:
              self.tracks[active_track_indices[i_invalid]].mark_missed()
  
          # keep the valid tracks for re-detection
          valid_track_numbers = np.nonzero(tracking_anchor_validity)[0]
          self.next_frame_pred_index = tracking_anchor_indices[
              valid_track_numbers, ...
          ]
          self.next_frame_pred_weights = tracking_anchor_weights[
              valid_track_numbers, ...
          ]
          self.next_frame_pred_bbox = predicted_track_boxes[
              valid_track_numbers, ...
          ]
          self.next_frame_pred_class = np.array(active_track_classes)[
              valid_track_numbers, ...
          ]
  
          active_track_indices = np.array(active_track_indices)[
              valid_track_numbers, ...
          ]
          active_track_boxes = active_track_boxes[
              valid_track_numbers, ...
          ]
  
      else:
          # skip flow computation if there is no active track
          # just save the frame in cache
          predicted_track_boxes = self._motion_prediction(
              new_frame,
              active_track_boxes,
              active_track_anchor_indices,
              active_track_anchor_weights,
              motion_pred_data,
              skip=True,
          )
  
          assert len(predicted_track_boxes) == 0
  
          self.next_frame_pred_index = np.array([])
          self.next_frame_pred_weights = np.array([])
          self.next_frame_pred_bbox = np.array([])
          self.next_frame_pred_class = np.array([])
  
      self.waiting_update_tracks = active_track_indices
      self.next_frame_ref_bbox = active_track_boxes
  
      return (
          self.next_frame_pred_index,
          self.next_frame_pred_weights,
          self.next_frame_pred_class,
      )
  
imports: from __future__ import absolute_import
  import logging
  import time
  import numpy
  import mxnet
  from gluoncv.utils.bbox import bbox_iou
  from gluoncv.data import COCODetection
  from .utils import timeit, Track
  from .motion_estimation import FarneBeckFlowMotionEstimator
  from .motion_estimation import DummyMotionEstimator
label_desc: Use image node_id 4 for calling the SMOTTracker obj's underlying member method code with example usage: obj.motion_predict(new_frame, motion_pred_data) and returns: self,  self,  self