aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/AreaOfInterest/AOI3DScene.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/argaze/AreaOfInterest/AOI3DScene.py')
-rw-r--r--src/argaze/AreaOfInterest/AOI3DScene.py27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/argaze/AreaOfInterest/AOI3DScene.py b/src/argaze/AreaOfInterest/AOI3DScene.py
index 44b8e3c..ee07043 100644
--- a/src/argaze/AreaOfInterest/AOI3DScene.py
+++ b/src/argaze/AreaOfInterest/AOI3DScene.py
@@ -133,8 +133,8 @@ class AOI3DScene(AOIFeatures.AOIScene):
file.write('s off\n')
file.write(vertices_ids + '\n')
- def clip(self, cone_radius, cone_height, cone_tip=[0., 0., 0.], cone_direction=[0., 0., 1.]):
- """Select AOI which are inside a given cone field.
+ def vision_cone(self, cone_radius, cone_height, cone_tip=[0., 0., 0.], cone_direction=[0., 0., 1.]):
+ """Get AOI which are inside and out a given cone field.
By default, the cone have the tip at origin and the base oriented to positive Z axis.
**Returns:** AOI3DScene"""
@@ -142,21 +142,14 @@ class AOI3DScene(AOIFeatures.AOIScene):
cone_tip = numpy.array(cone_tip).astype(numpy.float32)
cone_direction = numpy.array(cone_direction).astype(numpy.float32)
- # retreive rotation matrix from rotation vector
- R, _ = cv.Rodrigues(self.rotation)
-
- # store valid aoi into a new scene with same pose
- aoi3D_scene_clipped = AOI3DScene()
- aoi3D_scene_clipped.rotation = self.rotation
- aoi3D_scene_clipped.translation = self.translation
+ # sort aoi
+ aoi3D_scene_inside = AOI3DScene()
+ aoi3D_scene_outside = AOI3DScene()
for name, aoi3D in self.items():
- # rotate and translate back aoi to compensate the scene pose
- aoi3D_comp = aoi3D.dot(R.T) + self.translation
-
one_vertice_out = False
- for vertices in aoi3D_comp:
+ for vertices in aoi3D:
distance = numpy.dot(vertices - cone_tip, cone_direction)
radius = (distance / cone_height) * cone_radius
@@ -166,11 +159,13 @@ class AOI3DScene(AOIFeatures.AOIScene):
one_vertice_out = True
break
- # if no vertice is outside the cone, select the aoi
+ # if no vertice is outside the cone, aoi is inside
if not one_vertice_out:
- aoi3D_scene_clipped[name] = aoi3D
+ aoi3D_scene_inside[name] = aoi3D
+ else:
+ aoi3D_scene_outside[name] = aoi3D
- return aoi3D_scene_clipped
+ return aoi3D_scene_inside, aoi3D_scene_outside
def project(self, T=T0, R=R0, K=K0, D=D0):
"""Project 3D scene onto 2D scene according translation, rotation and optical parameters.