class_docstr: A simple Kalman filter for tracking bounding boxes in image space.
  
  The implementation is referred to https://github.com/nwojke/deep_sort.
  
  Args:
      center_only (bool): If True, distance computation is done with
          respect to the bounding box center position only.
          Defaults to False.
      use_nsa (bool): Whether to use the NSA (Noise Scale Adaptive) Kalman
          Filter, which adaptively modulates the noise scale according to
          the quality of detections. More details in
          https://arxiv.org/abs/2202.11983. Defaults to False.
class_docstr_tok: ["A","simple","Kalman","filter","for","tracking","bounding","boxes","in","image","space",".","The","implementation","is","referred","to","https",":","\/\/github.com\/nwojke\/deep_sort",".","Args",":","center_only","(","bool",")",":","If","True",",","distance","computation","is","done","with","respect","to","the","bounding","box","center","position","only",".","Defaults","to","False",".","use_nsa","(","bool",")",":","Whether","to","use","the","NSA","(","Noise","Scale","Adaptive",")","Kalman","Filter",",","which","adaptively","modulates","the","noise","scale","according","to","the","quality","of","detections",".","More","details","in","https",":","\/\/arxiv.org\/abs\/2202.11983",".","Defaults","to","False","."]
docstr: Compute gating distance between state distribution and measurements.
  
  A suitable distance threshold can be obtained from `chi2inv95`. If
  `only_position` is False, the chi-square distribution has 4 degrees of
  freedom, otherwise 2.
  
  Args:
      mean (ndarray): Mean vector over the state distribution (8
          dimensional).
      covariance (ndarray): Covariance of the state distribution (8x8
          dimensional).
      measurements (ndarray): An Nx4 dimensional matrix of N
          measurements, each in format (x, y, a, h) where (x, y) is the
          bounding box center position, a the aspect ratio, and h the
          height.
      only_position (bool, optional): If True, distance computation is
          done with respect to the bounding box center position only.
          Defaults to False.
  
  Returns:
      ndarray: Returns an array of length N, where the i-th element
      contains the squared Mahalanobis distance between
      (mean, covariance) and `measurements[i]`.
docstr_tok: ["Compute","gating","distance","between","state","distribution","and","measurements",".","A","suitable","distance","threshold","can","be","obtained","from","`","chi2inv95","`",".","If","`","only_position","`","is","False",",","the","chi-square","distribution","has","4","degrees","of","freedom",",","otherwise","2",".","Args",":","mean","(","ndarray",")",":","Mean","vector","over","the","state","distribution","(","8","dimensional",")",".","covariance","(","ndarray",")",":","Covariance","of","the","state","distribution","(","8x8","dimensional",")",".","measurements","(","ndarray",")",":","An","Nx4","dimensional","matrix","of","N","measurements",",","each","in","format","(","x",",","y",",","a",",","h",")","where","(","x",",","y",")","is","the","bounding","box","center","position",",","a","the","aspect","ratio",",","and","h","the","height",".","only_position","(","bool",",","optional",")",":","If","True",",","distance","computation","is","done","with","respect","to","the","bounding","box","center","position","only",".","Defaults","to","False",".","Returns",":","ndarray",":","Returns","an","array","of","length","N",",","where","the","i-th","element","contains","the","squared","Mahalanobis","distance","between","(","mean",",","covariance",")","and","`","measurements","[","i","]","`","."]
code: def gating_distance(
      self,
      mean: np.array,
      covariance: np.array,
      measurements: np.array,
      only_position: bool = False,
  ) -> np.array:
      """Compute gating distance between state distribution and measurements.
  
      A suitable distance threshold can be obtained from `chi2inv95`. If
      `only_position` is False, the chi-square distribution has 4 degrees of
      freedom, otherwise 2.
  
      Args:
          mean (ndarray): Mean vector over the state distribution (8
              dimensional).
          covariance (ndarray): Covariance of the state distribution (8x8
              dimensional).
          measurements (ndarray): An Nx4 dimensional matrix of N
              measurements, each in format (x, y, a, h) where (x, y) is the
              bounding box center position, a the aspect ratio, and h the
              height.
          only_position (bool, optional): If True, distance computation is
              done with respect to the bounding box center position only.
              Defaults to False.
  
      Returns:
          ndarray: Returns an array of length N, where the i-th element
          contains the squared Mahalanobis distance between
          (mean, covariance) and `measurements[i]`.
      """
      mean, covariance = self.project(mean, covariance)
      if only_position:
          mean, covariance = mean[:2], covariance[:2, :2]
          measurements = measurements[:, :2]
  
      cholesky_factor = np.linalg.cholesky(covariance)
      d = measurements - mean
      z = scipy.linalg.solve_triangular(
          cholesky_factor,
          d.T,
          lower=True,
          check_finite=False,
          overwrite_b=True,
      )
      squared_maha = np.sum(z * z, axis=0)
      return squared_maha
  
file_path: mmdetection/mmdet/models/task_modules/tracking/kalman_filter.py
imports: from typing import Tuple
  import numpy
  import torch
  from mmdet.registry import TASK_UTILS
label_desc: Use image node_id 6 for calling the KalmanFilter obj's underlying member method code with example usage: obj.gating_distance(mean, covariance, measurements, only_position) and returns: squared_maha