aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/AreaOfInterest/AOI2DScene.py
diff options
context:
space:
mode:
authorTheo De La Hogue2023-09-22 22:06:20 +0200
committerTheo De La Hogue2023-09-22 22:06:20 +0200
commitb947573f7dbccb5b2b13b64677192145f2dbb864 (patch)
tree20cd0cb471b245445bd493c3e8e24fa7baf45d8b /src/argaze/AreaOfInterest/AOI2DScene.py
parent1f36c34242791145a1b33dd17cf351018456310f (diff)
downloadargaze-b947573f7dbccb5b2b13b64677192145f2dbb864.zip
argaze-b947573f7dbccb5b2b13b64677192145f2dbb864.tar.gz
argaze-b947573f7dbccb5b2b13b64677192145f2dbb864.tar.bz2
argaze-b947573f7dbccb5b2b13b64677192145f2dbb864.tar.xz
Working on AOI frame feature: now 2D AOI in scene frame are merged into 3D AOI in scene layer.
Diffstat (limited to 'src/argaze/AreaOfInterest/AOI2DScene.py')
-rw-r--r--src/argaze/AreaOfInterest/AOI2DScene.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/argaze/AreaOfInterest/AOI2DScene.py b/src/argaze/AreaOfInterest/AOI2DScene.py
index 73c977f..f6b8dcb 100644
--- a/src/argaze/AreaOfInterest/AOI2DScene.py
+++ b/src/argaze/AreaOfInterest/AOI2DScene.py
@@ -10,7 +10,7 @@ __license__ = "BSD"
from typing import TypeVar, Tuple
from argaze import DataStructures
-from argaze.AreaOfInterest import AOIFeatures
+from argaze.AreaOfInterest import AOIFeatures, AOI3DScene
from argaze import GazeFeatures
import cv2
@@ -19,6 +19,9 @@ import numpy
AOI2DSceneType = TypeVar('AOI2DScene', bound="AOI2DScene")
# Type definition for type annotation convenience
+AOI3DSceneType = TypeVar('AOI3DScene', bound="AOI3DScene")
+# Type definition for type annotation convenience
+
class AOI2DScene(AOIFeatures.AOIScene):
"""Define AOI 2D scene."""
@@ -89,6 +92,7 @@ class AOI2DScene(AOIFeatures.AOIScene):
yield name, aoi, matched_region, aoi_ratio, circle_ratio
+ '''DEPRECATED: but maybe still usefull?
def reframe(self, aoi: AOIFeatures.AreaOfInterest, size: tuple) -> AOI2DSceneType:
"""
Reframe whole scene to a scene bounded by a 4 vertices 2D AOI.
@@ -120,3 +124,28 @@ class AOI2DScene(AOIFeatures.AOIScene):
aoi2D_scene[name] = numpy.matmul(aoi2D - Src_origin, M.T)
return aoi2D_scene
+ '''
+ def dimensionalize(self, frame_3d: AOIFeatures.AreaOfInterest, size: tuple) -> AOI3DSceneType:
+ """
+ Convert to 3D scene considering it is inside of 3D rectangular frame.
+
+ Parameters:
+ aoi_frame_3d: rectangle 3D AOI to use as referential plane
+ size: size of the frame in pixel
+
+ Returns:
+ AOI 3D scene
+ """
+
+ # Vectorize outter_axis function
+ vfunc = numpy.vectorize(frame_3d.outter_axis)
+
+ # Prepare new AOI 3D scene
+ aoi3D_scene = AOI3DScene.AOI3DScene()
+
+ for name, aoi2D in self.items():
+
+ X, Y = (aoi2D / size).T
+ aoi3D_scene[name] = numpy.array(vfunc(X, Y)).T.view(AOIFeatures.AreaOfInterest)
+
+ return aoi3D_scene