diff options
author | Théo de la Hogue | 2024-05-29 14:20:53 +0200 |
---|---|---|
committer | Théo de la Hogue | 2024-05-29 14:20:53 +0200 |
commit | 734f7291dd429203ad57c3dd69dd86d6af0ed138 (patch) | |
tree | d19e6ebac588e3b19fd00e226730b961c51cb61f | |
parent | a7c3362e9347affebf92dabcb96980e3bf6a2640 (diff) | |
download | argaze-734f7291dd429203ad57c3dd69dd86d6af0ed138.zip argaze-734f7291dd429203ad57c3dd69dd86d6af0ed138.tar.gz argaze-734f7291dd429203ad57c3dd69dd86d6af0ed138.tar.bz2 argaze-734f7291dd429203ad57c3dd69dd86d6af0ed138.tar.xz |
Removing unvalid AOI projection.
-rw-r--r-- | src/argaze/AreaOfInterest/AOI3DScene.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/argaze/AreaOfInterest/AOI3DScene.py b/src/argaze/AreaOfInterest/AOI3DScene.py index d50f9ff..13ea354 100644 --- a/src/argaze/AreaOfInterest/AOI3DScene.py +++ b/src/argaze/AreaOfInterest/AOI3DScene.py @@ -17,6 +17,7 @@ __credits__ = [] __copyright__ = "Copyright 2023, Ecole Nationale de l'Aviation Civile (ENAC)" __license__ = "GPLv3" +import logging import re from typing import Self @@ -174,8 +175,7 @@ class AOI3DScene(AOIFeatures.AOIScene): return self.project(tvec, rvec, K) ''' - def vision_cone(self, cone_radius, cone_height, cone_tip=[0., 0., 0.], cone_direction=[0., 0., 1.]) -> tuple[ - Self, Self]: + def vision_cone(self, cone_radius, cone_height, cone_tip=[0., 0., 0.], cone_direction=[0., 0., 1.]) -> tuple[Self, Self]: """Get AOI which are inside and out a given cone field. !!! note @@ -236,11 +236,18 @@ class AOI3DScene(AOIFeatures.AOIScene): aoi2D_scene = AOI2DScene.AOI2DScene() for name, aoi3D in self.items(): + vertices_2d, J = cv2.projectPoints(aoi3D.astype(numpy.float32), R, T, numpy.array(K), numpy.array(D)) - aoi2D = vertices_2d.reshape((len(vertices_2d), 2)).view(AOIFeatures.AreaOfInterest) + aoi2D = AOIFeatures.AreaOfInterest(vertices_2d.reshape((len(vertices_2d), 2))) + + if aoi2D.is_valid: + + aoi2D_scene[name] = aoi2D + + else: - aoi2D_scene[name] = aoi2D + logging.warning('AOI3DScene.project: %s AOI polygon is not valid.', name) return aoi2D_scene |