summaryrefslogtreecommitdiff
path: root/megapixels/app/models/bbox.py
diff options
context:
space:
mode:
authoradamhrv <adam@ahprojects.com>2019-01-18 11:00:18 +0100
committeradamhrv <adam@ahprojects.com>2019-01-18 11:00:18 +0100
commite06af50389f849be0bfe4fa97d39f4519ef2c711 (patch)
tree49755b51e1b8b1f8031e5483333570a8e9951272 /megapixels/app/models/bbox.py
parent03ad11fb2a3dcd425d50167b15d72d4e0ef536a2 (diff)
change to cli_proc
Diffstat (limited to 'megapixels/app/models/bbox.py')
-rw-r--r--megapixels/app/models/bbox.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/megapixels/app/models/bbox.py b/megapixels/app/models/bbox.py
index 608aaaf8..8ecc8971 100644
--- a/megapixels/app/models/bbox.py
+++ b/megapixels/app/models/bbox.py
@@ -252,11 +252,14 @@ class BBox:
# Create from
@classmethod
- def from_xywh_norm(cls, x, y, w, h):
+ def from_xywh_norm_dim(cls, x, y, w, h, dim):
"""Converts w, y, w, h to normalized BBox
:returns BBox
"""
- return cls(x, y, x + w, y + h)
+ x1, y1 = (x * dim[0], y * dim[1])
+ x2, y2 = (w * dim[0]) + x1, (h * dim[1]) + y1
+ rect = cls.normalize(cls, (x1, y1, x2, y2), dim)
+ return cls(*rect)
@classmethod
def from_xyxy_dim(cls, x1, y1, x2, y2, dim):