detection.py
Go to the documentation of this file.
1 # vim: expandtab:ts=4:sw=4
2 import numpy as np
3 
4 
6  """
7  This class represents a bounding box detection in a single image.
8 
9  Parameters
10  ----------
11  tlwh : array_like
12  Bounding box in format `(x, y, w, h)`.
13  confidence : float
14  Detector confidence score.
15  feature : array_like
16  A feature vector that describes the object contained in this image.
17 
18  Attributes
19  ----------
20  tlwh : ndarray
21  Bounding box in format `(top left x, top left y, width, height)`.
22  confidence : ndarray
23  Detector confidence score.
24  feature : ndarray | NoneType
25  A feature vector that describes the object contained in this image.
26 
27  """
28 
29  def __init__(self, tlwh, confidence, feature):
30  self.tlwh = np.asarray(tlwh, dtype=np.float)
31  self.confidence = float(confidence)
32  self.feature = np.asarray(feature, dtype=np.float32)
33 
34  def to_tlbr(self):
35  """Convert bounding box to format `(min x, min y, max x, max y)`, i.e.,
36  `(top left, bottom right)`.
37  """
38  ret = self.tlwh.copy()
39  ret[2:] += ret[:2]
40  return ret
41 
42  def to_xyah(self):
43  """Convert bounding box to format `(center x, center y, aspect ratio,
44  height)`, where the aspect ratio is `width / height`.
45  """
46  ret = self.tlwh.copy()
47  ret[:2] += ret[2:] / 2
48  ret[2] /= ret[3]
49  return ret
def __init__(self, tlwh, confidence, feature)
Definition: detection.py:29


jsk_perception
Author(s): Manabu Saito, Ryohei Ueda
autogenerated on Mon May 3 2021 03:03:27