summaryrefslogtreecommitdiff
path: root/megapixels/app/models/bbox.py
diff options
context:
space:
mode:
authoradamhrv <adam@ahprojects.com>2018-12-13 14:39:07 +0100
committeradamhrv <adam@ahprojects.com>2018-12-13 14:39:07 +0100
commitbd51b3cdf474c93b1d7c667d9e5a33159c97640a (patch)
tree6a5ae5524efa971cbd348cc2720d200fbeb2fecb /megapixels/app/models/bbox.py
parent49a49bebe3f972e93add837180f5672a4ae62ce0 (diff)
add pose, indexing
Diffstat (limited to 'megapixels/app/models/bbox.py')
-rw-r--r--megapixels/app/models/bbox.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/megapixels/app/models/bbox.py b/megapixels/app/models/bbox.py
index ccdf229e..e6da960e 100644
--- a/megapixels/app/models/bbox.py
+++ b/megapixels/app/models/bbox.py
@@ -45,8 +45,12 @@ class BBox:
self._tl = (x1, y1)
self._br = (x2, y2)
self._rect = (self._x1, self._y1, self._x2, self._y2)
+ self._area = self._width * self._height # as percentage
-
+ @property
+ def area(self):
+ return self._area
+
@property
def pt_tl(self):
return self._tl
@@ -178,23 +182,23 @@ class BBox:
# -----------------------------------------------------------------
# Format as
- def as_xyxy(self):
+ def to_xyxy(self):
"""Converts BBox back to x1, y1, x2, y2 rect"""
return (self._x1, self._y1, self._x2, self._y2)
- def as_xywh(self):
+ def to_xywh(self):
"""Converts BBox back to haar type"""
return (self._x1, self._y1, self._width, self._height)
- def as_trbl(self):
+ def to_trbl(self):
"""Converts BBox to CSS (top, right, bottom, left)"""
return (self._y1, self._x2, self._y2, self._x1)
- def as_dlib(self):
+ def to_dlib(self):
"""Converts BBox to dlib rect type"""
- return dlib.rectangle(self._x1, self._y1, self._x2, self._y2)
+ return dlib_rectangle(self._x1, self._y1, self._x2, self._y2)
- def as_yolo(self):
+ def to_yolo(self):
"""Converts BBox to normalized center x, center y, w, h"""
return (self._cx, self._cy, self._width, self._height)
@@ -256,8 +260,7 @@ class BBox:
"""
rect = (rect.left(), rect.top(), rect.right(), rect.bottom())
rect = cls.normalize(cls, rect, dim)
- return cls(*rect)
-
+ return cls(*rect)
def str(self):
"""Return BBox as a string "x1, y1, x2, y2" """