class_docstr: The objects returned by the tracker's `update` function on each iteration.
  
  They represent the objects currently being tracked by the tracker.
  
  Users should not instantiate TrackedObjects manually;
  the Tracker will be in charge of creating them.
  
  Attributes
  ----------
  estimate : np.ndarray
      Where the tracker predicts the point will be in the current frame based on past detections.
      A numpy array with the same shape as the detections being fed to the tracker that produced it.
  id : Optional[int]
      The unique identifier assigned to this object by the tracker. Set to `None` if the object is initializing.
  global_id : Optional[int]
      The globally unique identifier assigned to this object. Set to `None` if the object is initializing
  last_detection : Detection
      The last detection that matched with this tracked object.
      Useful if you are storing embeddings in your detections and want to do metric learning, or for debugging.
  last_distance : Optional[float]
      The distance the tracker had with the last object it matched with.
  age : int
      The age of this object measured in number of frames.
  live_points :
      A boolean mask with shape `(n_points,)`. Points marked as `True` have recently been matched with detections.
      Points marked as `False` haven't and are to be considered stale, and should be ignored.
  
      Functions like [`draw_tracked_objects`][norfair.drawing.draw_tracked_objects] use this property to determine which points not to draw.
  initializing_id : int
      On top of `id`, objects also have an `initializing_id` which is the id they are given internally by the `Tracker`;
      this id is used solely for debugging.
  
      Each new object created by the `Tracker` starts as an uninitialized `TrackedObject`,
      which needs to reach a certain match rate to be converted into a full blown `TrackedObject`.
      `initializing_id` is the id temporarily assigned to `TrackedObject` while they are getting initialized.
class_docstr_tok: ["The","objects","returned","by","the","tracker","'s","`","update","`","function","on","each","iteration",".","They","represent","the","objects","currently","being","tracked","by","the","tracker",".","Users","should","not","instantiate","TrackedObjects","manually",";","the","Tracker","will","be","in","charge","of","creating","them",".","Attributes","--","--","--","--","--","estimate",":","np.ndarray","Where","the","tracker","predicts","the","point","will","be","in","the","current","frame","based","on","past","detections",".","A","numpy","array","with","the","same","shape","as","the","detections","being","fed","to","the","tracker","that","produced","it",".","id",":","Optional","[","int","]","The","unique","identifier","assigned","to","this","object","by","the","tracker",".","Set","to","`","None","`","if","the","object","is","initializing",".","global_id",":","Optional","[","int","]","The","globally","unique","identifier","assigned","to","this","object",".","Set","to","`","None","`","if","the","object","is","initializing","last_detection",":","Detection","The","last","detection","that","matched","with","this","tracked","object",".","Useful","if","you","are","storing","embeddings","in","your","detections","and","want","to","do","metric","learning",",","or","for","debugging",".","last_distance",":","Optional","[","float","]","The","distance","the","tracker","had","with","the","last","object","it","matched","with",".","age",":","int","The","age","of","this","object","measured","in","number","of","frames",".","live_points",":","A","boolean","mask","with","shape","`","(","n_points",",",")","`",".","Points","marked","as","`","True","`","have","recently","been","matched","with","detections",".","Points","marked","as","`","False","`","have","n't","and","are","to","be","considered","stale",",","and","should","be","ignored",".","Functions","like","[","`","draw_tracked_objects","`","]","[","norfair.drawing.draw_tracked_objects","]","use","this","property","to","determine","which","points","not","to","draw",".","initializing_id",":","int","On","top","of","`","id","`",",","objects","also","have","an","`","initializing_id","`","which","is","the","id","they","are","given","internally","by","the","`","Tracker","`",";","this","id","is","used","solely","for","debugging",".","Each","new","object","created","by","the","`","Tracker","`","starts","as","an","uninitialized","`","TrackedObject","`",",","which","needs","to","reach","a","certain","match","rate","to","be","converted","into","a","full","blown","`","TrackedObject","`",".","`","initializing_id","`","is","the","id","temporarily","assigned","to","`","TrackedObject","`","while","they","are","getting","initialized","."]
docstr: Update tracked object with a new detection
  
  Parameters
  ----------
  detection : Detection
      the new detection matched to this tracked object
  period : int, optional
      frames corresponding to the period of time since last update.
docstr_tok: ["Update","tracked","object","with","a","new","detection","Parameters","--","--","--","--","--","detection",":","Detection","the","new","detection","matched","to","this","tracked","object","period",":","int",",","optional","frames","corresponding","to","the","period","of","time","since","last","update","."]
code: def hit(self, detection: "Detection", period: int = 1):
      """Update tracked object with a new detection
  
      Parameters
      ----------
      detection : Detection
          the new detection matched to this tracked object
      period : int, optional
          frames corresponding to the period of time since last update.
      """
      self._conditionally_add_to_past_detections(detection)
  
      self.last_detection = detection
      self.hit_counter = min(
          self.hit_counter + 2 * period, self.hit_counter_max
      )
  
      if (
          self.is_initializing
          and self.hit_counter > self.initialization_delay
      ):
          self.is_initializing = False
          self._acquire_ids()
  
      # We use a kalman filter in which we consider each coordinate on each point as a sensor.
      # This is a hacky way to update only certain sensors (only x, y coordinates for
      # points which were detected).
      # TODO: Use keypoint confidence information to change R on each sensor instead?
      if detection.scores is not None:
          assert len(detection.scores.shape) == 1
          points_over_threshold_mask = (
              detection.scores > self.detection_threshold
          )
          matched_sensors_mask = np.array(
              [
                  (m,) * self.dim_points
                  for m in points_over_threshold_mask
              ]
          ).flatten()
          H_pos = np.diag(matched_sensors_mask).astype(
              float
          )  # We measure x, y positions
          self.point_hit_counter[points_over_threshold_mask] += (
              2 * period
          )
      else:
          points_over_threshold_mask = np.array(
              [True] * self.num_points
          )
          H_pos = np.identity(self.num_points * self.dim_points)
          self.point_hit_counter += 2 * period
      self.point_hit_counter[
          self.point_hit_counter >= self.pointwise_hit_counter_max
      ] = self.pointwise_hit_counter_max
      self.point_hit_counter[self.point_hit_counter < 0] = 0
      H_vel = np.zeros(
          H_pos.shape
      )  # But we don't directly measure velocity
      H = np.hstack([H_pos, H_vel])
      self.filter.update(
          np.expand_dims(detection.absolute_points.flatten(), 0).T,
          None,
          H,
      )
  
      detected_at_least_once_mask = np.array(
          [
              (m,) * self.dim_points
              for m in self.detected_at_least_once_points
          ]
      ).flatten()
      now_detected_mask = np.hstack(
          (points_over_threshold_mask,) * self.dim_points
      ).flatten()
      first_detection_mask = np.logical_and(
          now_detected_mask, np.logical_not(detected_at_least_once_mask)
      )
  
      self.filter.x[: self.dim_z][
          first_detection_mask
      ] = np.expand_dims(detection.absolute_points.flatten(), 0).T[
          first_detection_mask
      ]
  
      # Force points being detected for the first time to have velocity = 0
      # This is needed because some detectors (like OpenPose) set points with
      # low confidence to coordinates (0, 0). And when they then get their first
      # real detection this creates a huge velocity vector in our KalmanFilter
      # and causes the tracker to start with wildly inaccurate estimations which
      # eventually coverge to the real detections.
      self.filter.x[self.dim_z :][
          np.logical_not(detected_at_least_once_mask)
      ] = 0
      self.detected_at_least_once_points = np.logical_or(
          self.detected_at_least_once_points, points_over_threshold_mask
      )
  
imports: from logging import warning
  from typing import Any, Callable, Hashable, List, Optional, Sequence, Tuple, Union
  import numpy
  from rich import print
  from norfair.camera_motion import CoordinatesTransformation
  from .distances import AVAILABLE_VECTORIZED_DISTANCES, ScalarDistance, get_distance_by_name
  from .filter import FilterFactory, OptimizedKalmanFilterFactory
  from .utils import validate_points
label_desc: Use image node_id 9 for calling the TrackedObject obj's underlying member method code with example usage: obj.hit(detection, period) without return types