class_docstr: Camera motion compensation.
  
  Args:
      warp_mode (str): Warp mode in opencv.
          Defaults to 'cv2.MOTION_EUCLIDEAN'.
      num_iters (int): Number of the iterations. Defaults to 50.
      stop_eps (float): Terminate threshold. Defaults to 0.001.
class_docstr_tok: ["Camera","motion","compensation",".","Args",":","warp_mode","(","str",")",":","Warp","mode","in","opencv",".","Defaults","to","'cv2.MOTION_EUCLIDEAN","'",".","num_iters","(","int",")",":","Number","of","the","iterations",".","Defaults","to","50.","stop_eps","(","float",")",":","Terminate","threshold",".","Defaults","to","0.001","."]
docstr: Tracking forward.
docstr_tok: ["Tracking","forward","."]
code: def track(
      self,
      img: Tensor,
      ref_img: Tensor,
      tracks: dict,
      num_samples: int,
      frame_id: int,
      metainfo: dict,
  ) -> dict:
      """Tracking forward."""
      img = img.squeeze(0).cpu().numpy().transpose((1, 2, 0))
      ref_img = ref_img.squeeze(0).cpu().numpy().transpose((1, 2, 0))
      warp_matrix = self.get_warp_matrix(img, ref_img)
  
      # rescale the warp_matrix due to the `resize` in pipeline
      scale_factor_h, scale_factor_w = metainfo["scale_factor"]
      warp_matrix[0, 2] = warp_matrix[0, 2] / scale_factor_w
      warp_matrix[1, 2] = warp_matrix[1, 2] / scale_factor_h
  
      bboxes = []
      num_bboxes = []
      means = []
      for k, v in tracks.items():
          if int(v["frame_ids"][-1]) < frame_id - 1:
              _num = 1
          else:
              _num = min(num_samples, len(v.bboxes))
          num_bboxes.append(_num)
          bboxes.extend(v.bboxes[-_num:])
          if len(v.mean) > 0:
              means.append(v.mean)
      bboxes = torch.cat(bboxes, dim=0)
      warped_bboxes = self.warp_bboxes(
          bboxes, warp_matrix.to(bboxes.device)
      )
  
      warped_bboxes = torch.split(warped_bboxes, num_bboxes)
      for b, (k, v) in zip(warped_bboxes, tracks.items()):
          _num = b.shape[0]
          b = torch.split(b, [1] * _num)
          tracks[k].bboxes[-_num:] = b
  
      if means:
          means = np.asarray(means)
          warped_means = self.warp_means(means, warp_matrix)
          for m, (k, v) in zip(warped_means, tracks.items()):
              tracks[k].mean = m
  
      return tracks
  
file_path: mmdetection/mmdet/models/task_modules/tracking/camera_motion_compensation.py
imports: import cv2
  import numpy
  import torch
  from torch import Tensor
  from mmdet.registry import TASK_UTILS
  from mmdet.structures.bbox import bbox_cxcyah_to_xyxy, bbox_xyxy_to_cxcyah
label_desc: Use image node_id 5 for calling the CameraMotionCompensation obj's underlying member method code with example usage: obj.track(img, ref_img, tracks, num_samples, frame_id, metainfo) and returns: tracks