diff options
author | Théo de la Hogue | 2022-05-09 15:36:32 +0200 |
---|---|---|
committer | Théo de la Hogue | 2022-05-09 15:36:32 +0200 |
commit | 931e282654cee682c2f54694a52364e4e3599be9 (patch) | |
tree | 44b3b1eeff75f718f4b2f0dd1e1bc5a76a113948 | |
parent | 697dbe4837bebab1faa116b508706eb165746c75 (diff) | |
download | argaze-931e282654cee682c2f54694a52364e4e3599be9.zip argaze-931e282654cee682c2f54694a52364e4e3599be9.tar.gz argaze-931e282654cee682c2f54694a52364e4e3599be9.tar.bz2 argaze-931e282654cee682c2f54694a52364e4e3599be9.tar.xz |
Adding a bounding box method.
-rw-r--r-- | src/argaze/AreaOfInterest/AOIFeatures.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/argaze/AreaOfInterest/AOIFeatures.py b/src/argaze/AreaOfInterest/AOIFeatures.py index 8b93935..0d9fce0 100644 --- a/src/argaze/AreaOfInterest/AOIFeatures.py +++ b/src/argaze/AreaOfInterest/AOIFeatures.py @@ -16,6 +16,14 @@ class AreaOfInterest(numpy.ndarray): """Number of coordinates coding area points positions.""" return self.shape[1] + def bounding_box(self): + """Get area's bounding box.""" + + min_x, min_y = numpy.min(self, axis=0) + max_x, max_y = numpy.max(self, axis=0) + + return numpy.array([(min_x, min_y), (max_x, min_y), (max_x, max_y), (min_x, max_y)]) + def center(self): """Center of mass""" return self.mean(axis=0) |