aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoCamera.py83
-rw-r--r--src/argaze.test/ArUcoMarkers/utils/aruco_camera.json39
-rw-r--r--src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py3
-rw-r--r--src/argaze.test/GazeFeatures.py3
-rw-r--r--src/argaze/ArFeatures.py6
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoCamera.py4
-rw-r--r--src/argaze/DataFeatures.py4
-rw-r--r--src/argaze/GazeFeatures.py3
8 files changed, 78 insertions, 67 deletions
diff --git a/src/argaze.test/ArUcoMarkers/ArUcoCamera.py b/src/argaze.test/ArUcoMarkers/ArUcoCamera.py
index 6145f40..a3c5943 100644
--- a/src/argaze.test/ArUcoMarkers/ArUcoCamera.py
+++ b/src/argaze.test/ArUcoMarkers/ArUcoCamera.py
@@ -25,49 +25,46 @@ class TestArUcoCameraClass(unittest.TestCase):
json_filepath = os.path.join(current_directory, 'utils/aruco_camera.json')
# Load test aruco camera
- aruco_camera = ArUcoCamera.ArUcoCamera.from_json(json_filepath)
-
- # Check aruco camera meta data
- self.assertEqual(aruco_camera.name, "TestArUcoCamera")
-
- # Check ArUco detector
- self.assertEqual(aruco_camera.aruco_detector.dictionary.name, "DICT_ARUCO_ORIGINAL")
- self.assertEqual(aruco_camera.aruco_detector.marker_size, 3.0)
- self.assertEqual(aruco_camera.aruco_detector.parameters.cornerRefinementMethod, 3)
- self.assertEqual(aruco_camera.aruco_detector.parameters.aprilTagQuadSigma, 2)
- self.assertEqual(aruco_camera.aruco_detector.parameters.aprilTagDeglitch, 1)
-
- # Check ArUco detector optic parameters
- self.assertEqual(aruco_camera.aruco_detector.optic_parameters.rms, 1.0)
- self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.aruco_detector.optic_parameters.dimensions, [1920, 1080]))
- self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.aruco_detector.optic_parameters.K, [[1.0, 0.0, 1.0], [0.0, 1.0, 1.0], [0.0, 0.0, 1.0]]))
- self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.aruco_detector.optic_parameters.D, [-1.0, -0.5, 0.0, 0.5, 1.0]))
-
- # Check camera scenes
- self.assertEqual(len(aruco_camera.scenes), 2)
- self.assertIsNone(numpy.testing.assert_array_equal(list(aruco_camera.scenes.keys()), ["TestSceneA", "TestSceneB"]))
-
- # Load test scene
- ar_scene = aruco_camera.scenes["TestSceneA"]
-
- # Check Aruco scene
- self.assertEqual(len(ar_scene.aruco_markers_group.places), 2)
- self.assertIsNone(numpy.testing.assert_array_equal(ar_scene.aruco_markers_group.places[0].translation, [1, 0, 0]))
- self.assertIsNone(numpy.testing.assert_array_equal(ar_scene.aruco_markers_group.places[0].rotation, [[1.,0.,0.],[0.,1.,0.],[0.,0.,1.]]))
- self.assertEqual(ar_scene.aruco_markers_group.places[0].marker.identifier, 0)
-
- self.assertIsNone(numpy.testing.assert_array_equal(ar_scene.aruco_markers_group.places[1].translation, [0, 1, 0]))
- self.assertIsNone(numpy.testing.assert_array_almost_equal(ar_scene.aruco_markers_group.places[1].rotation, [[0.,0.,1.],[0., 1.,0.],[-1.,0.,0.]]))
- self.assertEqual(ar_scene.aruco_markers_group.places[1].marker.identifier, 1)
-
- # Check AOI scene
- self.assertEqual(len(ar_scene.aoi_scene.items()), 1)
- self.assertEqual(ar_scene.aoi_scene['Test'].points_number, 4)
- self.assertIsNone(numpy.testing.assert_array_equal(ar_scene.aoi_scene['Test'].size, [1., 1., 0.]))
-
- # Check ArScene
- self.assertEqual(ar_scene.angle_tolerance, 1.0)
- self.assertEqual(ar_scene.distance_tolerance, 2.0)
+ with ArUcoCamera.ArUcoCamera.from_json(json_filepath) as aruco_camera:
+
+ # Check aruco camera meta data
+ self.assertEqual(aruco_camera.name, "TestArUcoCamera")
+
+ # Check ArUco detector
+ self.assertEqual(aruco_camera.aruco_detector.dictionary.name, "DICT_ARUCO_ORIGINAL")
+ self.assertEqual(aruco_camera.aruco_detector.parameters.cornerRefinementMethod, 3)
+ self.assertEqual(aruco_camera.aruco_detector.parameters.aprilTagQuadSigma, 2)
+ self.assertEqual(aruco_camera.aruco_detector.parameters.aprilTagDeglitch, 1)
+
+ # Check ArUco detector optic parameters
+ self.assertEqual(aruco_camera.aruco_detector.optic_parameters.rms, 1.0)
+ self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.aruco_detector.optic_parameters.dimensions, [1920, 1080]))
+ self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.aruco_detector.optic_parameters.K, [[1.0, 0.0, 1.0], [0.0, 1.0, 1.0], [0.0, 0.0, 1.0]]))
+ self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.aruco_detector.optic_parameters.D, [-1.0, -0.5, 0.0, 0.5, 1.0]))
+
+ # Check camera scenes
+ self.assertEqual(len(aruco_camera.scenes), 2)
+ self.assertIsNone(numpy.testing.assert_array_equal(list(aruco_camera.scenes.keys()), ["TestSceneA", "TestSceneB"]))
+
+ # Load test scene
+ ar_scene = aruco_camera.scenes["TestSceneA"]
+
+ # Check Aruco scene
+ self.assertEqual(len(ar_scene.aruco_markers_group.places), 2)
+ self.assertIsNone(numpy.testing.assert_allclose(ar_scene.aruco_markers_group.places[0].corners[0], [-0.5, 1.5, 0.], rtol=0, atol=1e-3))
+ self.assertEqual(ar_scene.aruco_markers_group.places[0].marker.identifier, 0)
+
+ self.assertIsNone(numpy.testing.assert_allclose(ar_scene.aruco_markers_group.places[1].corners[0], [0., 2.5, -1.5], rtol=0, atol=1e-3))
+ self.assertEqual(ar_scene.aruco_markers_group.places[1].marker.identifier, 1)
+
+ # Check layers and AOI scene
+ self.assertEqual(len(ar_scene.layers.items()), 1)
+ self.assertEqual(len(ar_scene.layers["Main"].aoi_scene), 1)
+ self.assertEqual(ar_scene.layers["Main"].aoi_scene['Test'].points_number, 4)
+
+ # Check ArScene
+ self.assertEqual(ar_scene.angle_tolerance, 1.0)
+ self.assertEqual(ar_scene.distance_tolerance, 2.0)
if __name__ == '__main__':
diff --git a/src/argaze.test/ArUcoMarkers/utils/aruco_camera.json b/src/argaze.test/ArUcoMarkers/utils/aruco_camera.json
index 7648916..980dc9f 100644
--- a/src/argaze.test/ArUcoMarkers/utils/aruco_camera.json
+++ b/src/argaze.test/ArUcoMarkers/utils/aruco_camera.json
@@ -1,10 +1,10 @@
{
"name": "TestArUcoCamera",
+ "size": [1920, 1080],
"aruco_detector": {
"dictionary": {
"name": "DICT_ARUCO_ORIGINAL"
},
- "marker_size": 3.0,
"optic_parameters": {
"rms": 1.0,
"dimensions": [
@@ -45,45 +45,54 @@
"scenes": {
"TestSceneA" : {
"aruco_markers_group": {
- "marker_size": 3.0,
- "dictionary": {
- "name": "DICT_ARUCO_ORIGINAL"
- },
+ "dictionary": "DICT_ARUCO_ORIGINAL",
"places": {
"0": {
"translation": [1, 0, 0],
- "rotation": [0, 0, 0]
+ "rotation": [0, 0, 0],
+ "size": 3.0
},
"1": {
"translation": [0, 1, 0],
- "rotation": [0, 90, 0]
+ "rotation": [0, 90, 0],
+ "size": 3.0
}
}
},
- "aoi_scene": "aoi.obj",
+ "layers": {
+ "Main" : {
+ "aoi_scene": "aoi_3d.obj"
+ }
+ },
"angle_tolerance": 1.0,
"distance_tolerance": 2.0
},
"TestSceneB" : {
"aruco_markers_group": {
- "marker_size": 3.0,
- "dictionary": {
- "name": "DICT_ARUCO_ORIGINAL"
- },
+ "dictionary": "DICT_ARUCO_ORIGINAL",
"places": {
"0": {
"translation": [1, 0, 0],
- "rotation": [0, 0, 0]
+ "rotation": [0, 0, 0],
+ "size": 3.0
},
"1": {
"translation": [0, 1, 0],
- "rotation": [0, 90, 0]
+ "rotation": [0, 90, 0],
+ "size": 3.0
}
}
},
- "aoi_scene": "aoi.obj",
+ "layers": {
+ "Main" : {
+ "aoi_scene": "aoi_3d.obj"
+ }
+ },
"angle_tolerance": 1.0,
"distance_tolerance": 2.0
}
+ },
+ "layers": {
+ "Main": {}
}
} \ No newline at end of file
diff --git a/src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py b/src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py
index 311f31b..156f6f1 100644
--- a/src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py
+++ b/src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py
@@ -113,9 +113,6 @@ class TestDispersionThresholdIdentificationClass(unittest.TestCase):
gaze_movement_identifier = DispersionThresholdIdentification.GazeMovementIdentifier(deviation_max_threshold=deviation_max, duration_min_threshold=max_time*2)
ts_fixations, ts_saccades, ts_status = gaze_movement_identifier.browse(ts_gaze_positions)
- # DEBUG
- print(gaze_movement_identifier)
-
# Check result size
self.assertEqual(len(ts_fixations), 1)
self.assertEqual(len(ts_saccades), 0)
diff --git a/src/argaze.test/GazeFeatures.py b/src/argaze.test/GazeFeatures.py
index e678093..c0c014c 100644
--- a/src/argaze.test/GazeFeatures.py
+++ b/src/argaze.test/GazeFeatures.py
@@ -31,9 +31,6 @@ def random_gaze_positions(size, frame_dimension: tuple[float, float] = (1, 1)):
# Edit gaze position
random_gaze_position = GazeFeatures.GazePosition((random.random() * frame_dimension[0], random.random() * frame_dimension[1]), precision=5)
- # DEBUG
- print('random_gaze_position', type(random_gaze_position), random_gaze_position.__class__.__bases__)
-
# Timestamp gaze position
random_gaze_position.timestamp = time.time()
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py
index 8005d48..95d89d9 100644
--- a/src/argaze/ArFeatures.py
+++ b/src/argaze/ArFeatures.py
@@ -882,11 +882,17 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject):
!!! warning
Be aware that gaze positions are in the same range of value than size attribute.
+ !!! note
+ This method timestamps incoming gaze position.
+
Parameters:
timestamp: method call timestamp (unit does'nt matter)
gaze_position: gaze position to project
"""
+ # Timestamp gaze position
+ gaze_position.timestamp = timestamp
+
# Use frame lock feature
with self._lock:
diff --git a/src/argaze/ArUcoMarkers/ArUcoCamera.py b/src/argaze/ArUcoMarkers/ArUcoCamera.py
index 7f30252..f6297a8 100644
--- a/src/argaze/ArUcoMarkers/ArUcoCamera.py
+++ b/src/argaze/ArUcoMarkers/ArUcoCamera.py
@@ -187,8 +187,8 @@ class ArUcoCamera(ArFeatures.ArCamera):
pass
- # Timestamp camera frame
- self.timestamp = timestamp
+ # Timestamp camera frame
+ self.timestamp = timestamp
def __image(self, draw_detected_markers: dict = None, draw_scenes: dict = None, draw_optic_parameters_grid: dict = None, **kwargs: dict) -> numpy.array:
"""Get frame image with ArUco detection visualisation.
diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py
index 8df991b..849601f 100644
--- a/src/argaze/DataFeatures.py
+++ b/src/argaze/DataFeatures.py
@@ -196,8 +196,10 @@ class TimestampedObjectsList(list):
raise TypeError(f'{type(ts_object)} object is not {self.__object_type} instance')
- assert(ts_object.is_timestamped())
+ if not ts_object.is_timestamped():
+ raise ValueError(f'object is not timestamped')
+
super().append(ts_object)
def look_for(self, timestamp: TimeStampType) -> TimestampedObjectType:
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py
index 6a02142..263f793 100644
--- a/src/argaze/GazeFeatures.py
+++ b/src/argaze/GazeFeatures.py
@@ -363,6 +363,9 @@ GazeMovementType = TypeVar('GazeMovement', bound="GazeMovement")
class GazeMovement(TimeStampedGazePositions, DataFeatures.TimestampedObject):
"""Define abstract gaze movement class as timestamped gaze positions list.
+ !!! note
+ Gaze movement timestamp is always equal to its first position timestamp.
+
Parameters:
positions: timestamp gaze positions.
finished: is the movement finished?