class_docstr: ScalarDistance class represents a distance that is calculated pointwise.
  
  Parameters
  ----------
  distance_function : Union[Callable[["Detection", "TrackedObject"], float], Callable[["TrackedObject", "TrackedObject"], float]]
      Distance function used to determine the pointwise distance between new candidates and objects.
      This function should take 2 input arguments, the first being a `Union[Detection, TrackedObject]`,
      and the second [TrackedObject][norfair.tracker.TrackedObject]. It has to return a `float` with the distance it calculates.
docstr: Method that calculates the distances between new candidates and objects.
  
  Parameters
  ----------
  objects : Sequence[TrackedObject]
      Sequence of [TrackedObject][norfair.tracker.TrackedObject] to be compared with potential [Detection][norfair.tracker.Detection] or [TrackedObject][norfair.tracker.TrackedObject]
      candidates.
  candidates : Union[List[Detection], List[TrackedObject]], optional
      List of candidates ([Detection][norfair.tracker.Detection] or [TrackedObject][norfair.tracker.TrackedObject]) to be compared to [TrackedObject][norfair.tracker.TrackedObject].
  
  Returns
  -------
  np.ndarray
      A matrix containing the distances between objects and candidates.
docstr_tok: ["Method","that","calculates","the","distances","between","new","candidates","and","objects",".","Parameters","--","--","--","--","--","objects",":","Sequence","[","TrackedObject","]","Sequence","of","[","TrackedObject","]","[","norfair.tracker.TrackedObject","]","to","be","compared","with","potential","[","Detection","]","[","norfair.tracker.Detection","]","or","[","TrackedObject","]","[","norfair.tracker.TrackedObject","]","candidates",".","candidates",":","Union","[","List","[","Detection","]",",","List","[","TrackedObject","]","]",",","optional","List","of","candidates","(","[","Detection","]","[","norfair.tracker.Detection","]","or","[","TrackedObject","]","[","norfair.tracker.TrackedObject","]",")","to","be","compared","to","[","TrackedObject","]","[","norfair.tracker.TrackedObject","]",".","Returns","--","--","--","-","np.ndarray","A","matrix","containing","the","distances","between","objects","and","candidates","."]
code: def get_distances(
      self,
      objects: Sequence["TrackedObject"],
      candidates: Optional[
          Union[List["Detection"], List["TrackedObject"]]
      ],
  ) -> np.ndarray:
      """
      Method that calculates the distances between new candidates and objects.
  
      Parameters
      ----------
      objects : Sequence[TrackedObject]
          Sequence of [TrackedObject][norfair.tracker.TrackedObject] to be compared with potential [Detection][norfair.tracker.Detection] or [TrackedObject][norfair.tracker.TrackedObject]
          candidates.
      candidates : Union[List[Detection], List[TrackedObject]], optional
          List of candidates ([Detection][norfair.tracker.Detection] or [TrackedObject][norfair.tracker.TrackedObject]) to be compared to [TrackedObject][norfair.tracker.TrackedObject].
  
      Returns
      -------
      np.ndarray
          A matrix containing the distances between objects and candidates.
      """
      distance_matrix = np.full(
          (len(candidates), len(objects)),
          fill_value=np.inf,
          dtype=np.float32,
      )
      if not objects or not candidates:
          return distance_matrix
      for c, candidate in enumerate(candidates):
          for o, obj in enumerate(objects):
              if candidate.label != obj.label:
                  if (candidate.label is None) or (obj.label is None):
                      print(
                          "\nThere are detections with and without label!"
                      )
                  continue
              distance = self.distance_function(candidate, obj)
              distance_matrix[c, o] = distance
      return distance_matrix
  
imports: from abc import ABC, abstractmethod
  from functools import partial
  from logging import warning
  from typing import TYPE_CHECKING, Callable, List, Optional, Sequence, Union
  import numpy
  from scipy.spatial.distance import cdist
label_desc: Use image node_id 2 for calling the ScalarDistance obj's underlying member method code with example usage: obj.get_distances(objects, candidates) and returns: distance_matrix, distance_matrix