Bounding Box as a python class with utility methods
Properties
----------
minX : int
top left x coordinate
minY : int
top left y coordinate
width : int
width of the bounding box
height : int
height of the bounding box
Definition at line 24 of file bbox.py.
Self coretex.entities.annotation.image.bbox.BBox.fromPoly |
( |
|
cls, |
|
|
List[int] |
polygon |
|
) |
| |
Creates bounding box from a polygon, by finding
the minimum x and y coordinates and calculating
width and height of the polygon
Parameters
----------
polygon : List[int]
list of x, y points - length must be even
Returns
-------
Self -> bounding box
Example
-------
>>> from coretex import Bbox
\b
>>> polygon = [0, 0, 0, 3, 4, 3, 4, 0]
>>> bbox = Bbox.fromPoly(polygon)
>>> print(f"minX: {bbox.minX}, minY: {bbox.minY}, width: {bbox.width}, height: {bbox.height}")
"minX: 0, minY: 0, width: 4, height: 3"
Definition at line 122 of file bbox.py.
122 def fromPoly(cls, polygon: List[int]) -> Self:
124 Creates bounding box from a polygon, by finding
125 the minimum x and y coordinates and calculating
126 width and height of the polygon
131 list of x, y points - length must be even
139 >>> from coretex import Bbox
141 >>> polygon = [0, 0, 0, 3, 4, 3, 4, 0]
142 >>> bbox = Bbox.fromPoly(polygon)
143 >>> print(f"minX: {bbox.minX}, minY: {bbox.minY}, width: {bbox.width}, height: {bbox.height}")
144 "minX: 0, minY: 0, width: 4, height: 3"
150 for index, value
in enumerate(polygon):
156 return cls.create(min(x), min(y), max(x), max(y))