diff options
-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 |