detection.py
Go to the documentation of this file.
00001 # vim: expandtab:ts=4:sw=4
00002 import numpy as np
00003 
00004 
00005 class Detection(object):
00006     """
00007     This class represents a bounding box detection in a single image.
00008 
00009     Parameters
00010     ----------
00011     tlwh : array_like
00012         Bounding box in format `(x, y, w, h)`.
00013     confidence : float
00014         Detector confidence score.
00015     feature : array_like
00016         A feature vector that describes the object contained in this image.
00017 
00018     Attributes
00019     ----------
00020     tlwh : ndarray
00021         Bounding box in format `(top left x, top left y, width, height)`.
00022     confidence : ndarray
00023         Detector confidence score.
00024     feature : ndarray | NoneType
00025         A feature vector that describes the object contained in this image.
00026 
00027     """
00028 
00029     def __init__(self, tlwh, confidence, feature):
00030         self.tlwh = np.asarray(tlwh, dtype=np.float)
00031         self.confidence = float(confidence)
00032         self.feature = np.asarray(feature, dtype=np.float32)
00033 
00034     def to_tlbr(self):
00035         """Convert bounding box to format `(min x, min y, max x, max y)`, i.e.,
00036         `(top left, bottom right)`.
00037         """
00038         ret = self.tlwh.copy()
00039         ret[2:] += ret[:2]
00040         return ret
00041 
00042     def to_xyah(self):
00043         """Convert bounding box to format `(center x, center y, aspect ratio,
00044         height)`, where the aspect ratio is `width / height`.
00045         """
00046         ret = self.tlwh.copy()
00047         ret[:2] += ret[2:] / 2
00048         ret[2] /= ret[3]
00049         return ret


jsk_perception
Author(s): Manabu Saito, Ryohei Ueda
autogenerated on Tue Jul 2 2019 19:41:07