Bounding Box as a python class with utility methods
Properties
----------
minX : float
top left x coordinate
minY : float
top left y coordinate
width : float
width of the bounding box
height : float
height of the bounding box
Definition at line 24 of file bbox.py.
Self coretex.coretex.annotation.image.bbox.BBox.fromPoly |
( |
|
cls, |
|
|
List[float] |
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[float]
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 118 of file bbox.py.
118 def fromPoly(cls, polygon: List[float]) -> Self:
120 Creates bounding box from a polygon, by finding
121 the minimum x and y coordinates and calculating
122 width and height of the polygon
126 polygon : List[float]
127 list of x, y points - length must be even
135 >>> from coretex import Bbox
137 >>> polygon = [0, 0, 0, 3, 4, 3, 4, 0]
138 >>> bbox = Bbox.fromPoly(polygon)
139 >>> print(f"minX: {bbox.minX}, minY: {bbox.minY}, width: {bbox.width}, height: {bbox.height}")
140 "minX: 0, minY: 0, width: 4, height: 3"
146 for index, value
in enumerate(polygon):
152 return cls.create(min(x), min(y), max(x), max(y))