diff options
author | Théo de la Hogue | 2023-09-27 18:03:57 +0200 |
---|---|---|
committer | Théo de la Hogue | 2023-09-27 18:03:57 +0200 |
commit | 66b84b019fe760a2cb9901a9f17b2d202d935ba4 (patch) | |
tree | f7d55fbf6522cb6e94f02b9ff2001ca4a0ac516c | |
parent | eddfdc69b27c1b32ba0001ba4f147810eabec549 (diff) | |
download | argaze-66b84b019fe760a2cb9901a9f17b2d202d935ba4.zip argaze-66b84b019fe760a2cb9901a9f17b2d202d935ba4.tar.gz argaze-66b84b019fe760a2cb9901a9f17b2d202d935ba4.tar.bz2 argaze-66b84b019fe760a2cb9901a9f17b2d202d935ba4.tar.xz |
Allowing to load ellipse from SVG file.
-rw-r--r-- | src/argaze/AreaOfInterest/AOI2DScene.py | 15 | ||||
-rw-r--r-- | src/argaze/AreaOfInterest/AOIFeatures.py | 11 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/argaze/AreaOfInterest/AOI2DScene.py b/src/argaze/AreaOfInterest/AOI2DScene.py index f8599c5..062044f 100644 --- a/src/argaze/AreaOfInterest/AOI2DScene.py +++ b/src/argaze/AreaOfInterest/AOI2DScene.py @@ -91,6 +91,21 @@ class AOI2DScene(AOIFeatures.AOIScene): new_areas[circle.getAttribute('id')] = AOIFeatures.AreaOfInterest.from_dict(circle_dict) + # Load SVG ellipse + for ellipse in description_file.getElementsByTagName('ellipse'): + + # Convert ellipse element into dict + ellipse_dict = { + "Ellipse": { + 'cx': float(circle.getAttribute('cx')), + 'cy': float(circle.getAttribute('cy')), + 'rx': float(circle.getAttribute('rx')), + 'ry': float(circle.getAttribute('ry')) + } + } + + new_areas[ellipse.getAttribute('id')] = AOIFeatures.AreaOfInterest.from_dict(ellipse_dict) + return AOI2DScene(new_areas) def draw(self, image: numpy.array, draw_aoi: dict = None, exclude=[]): diff --git a/src/argaze/AreaOfInterest/AOIFeatures.py b/src/argaze/AreaOfInterest/AOIFeatures.py index dfbb165..2d5b9b1 100644 --- a/src/argaze/AreaOfInterest/AOIFeatures.py +++ b/src/argaze/AreaOfInterest/AOIFeatures.py @@ -78,6 +78,17 @@ class AreaOfInterest(numpy.ndarray): return AreaOfInterest(points) + elif shape == 'Ellipse': + + cx = shape_data.pop('cx') + cy = shape_data.pop('cy') + rx = shape_data.pop('rx') + ry = shape_data.pop('ry') + + # TODO: Use pygeos + N = 32 + points = [(math.cos(2*math.pi / N*x) * rx + cx, math.sin(2*math.pi / N*x) * ry + cy) for x in range(0, N+1)] + @property def dimension(self) -> int: """Number of axis coding area points positions.""" |