aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2023-04-24 17:00:16 +0200
committerThéo de la Hogue2023-04-24 17:00:16 +0200
commit7181f1587cd4d78c34d4dba740f1a5b7b2a5856c (patch)
treee5b9a604ccae2c0bc5662786067f032bfcb86c83 /src
parent8d31f9d273b56e4fe5df8b588a79900173a296ee (diff)
downloadargaze-7181f1587cd4d78c34d4dba740f1a5b7b2a5856c.zip
argaze-7181f1587cd4d78c34d4dba740f1a5b7b2a5856c.tar.gz
argaze-7181f1587cd4d78c34d4dba740f1a5b7b2a5856c.tar.bz2
argaze-7181f1587cd4d78c34d4dba740f1a5b7b2a5856c.tar.xz
Loading ArUco scene directly from dict with several rotation values format.
Diffstat (limited to 'src')
-rw-r--r--src/argaze.test/utils/environment.json36
-rw-r--r--src/argaze/ArFeatures.py2
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoScene.py20
3 files changed, 43 insertions, 15 deletions
diff --git a/src/argaze.test/utils/environment.json b/src/argaze.test/utils/environment.json
index 17920d8..57d04cf 100644
--- a/src/argaze.test/utils/environment.json
+++ b/src/argaze.test/utils/environment.json
@@ -45,13 +45,19 @@
"scenes": {
"TestSceneA" : {
"aruco_scene": {
- "0": {
- "translation": [1, 0, 0],
- "rotation": [0, 0, 0]
+ "marker_size": 3.0,
+ "dictionary": {
+ "name": "DICT_ARUCO_ORIGINAL"
},
- "1": {
- "translation": [0, 1, 0],
- "rotation": [0, 90, 0]
+ "places": {
+ "0": {
+ "translation": [1, 0, 0],
+ "rotation": [0, 0, 0]
+ },
+ "1": {
+ "translation": [0, 1, 0],
+ "rotation": [0, 90, 0]
+ }
}
},
"aoi_scene": "aoi.obj",
@@ -60,13 +66,19 @@
},
"TestSceneB" : {
"aruco_scene": {
- "0": {
- "translation": [1, 0, 0],
- "rotation": [0, 0, 0]
+ "marker_size": 3.0,
+ "dictionary": {
+ "name": "DICT_ARUCO_ORIGINAL"
},
- "1": {
- "translation": [0, 1, 0],
- "rotation": [0, 90, 0]
+ "places": {
+ "0": {
+ "translation": [1, 0, 0],
+ "rotation": [0, 0, 0]
+ },
+ "1": {
+ "translation": [0, 1, 0],
+ "rotation": [0, 90, 0]
+ }
}
},
"aoi_scene": "aoi.obj",
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py
index 112b7d1..e645ec7 100644
--- a/src/argaze/ArFeatures.py
+++ b/src/argaze/ArFeatures.py
@@ -89,7 +89,7 @@ class ArEnvironment():
# dict:
else:
- new_aruco_scene = ArUcoScene.ArUcoScene(new_aruco_detector.marker_size, new_aruco_detector.dictionary, aruco_scene_value)
+ new_aruco_scene = ArUcoScene.ArUcoScene(**aruco_scene_value)
# Check aoi_scene value type
aoi_scene_value = scene_data.pop('aoi_scene')
diff --git a/src/argaze/ArUcoMarkers/ArUcoScene.py b/src/argaze/ArUcoMarkers/ArUcoScene.py
index 868e84d..f5660dc 100644
--- a/src/argaze/ArUcoMarkers/ArUcoScene.py
+++ b/src/argaze/ArUcoMarkers/ArUcoScene.py
@@ -85,9 +85,25 @@ class ArUcoScene():
identifier = int(identifier)
- # Convert translation and rotation values
+ # Get translation vector
tvec = numpy.array(place.pop('translation')).astype(numpy.float32)
- rmat = make_rotation_matrix(*place.pop('rotation')).astype(numpy.float32)
+
+ # Check rotation value shape
+ rvalue = numpy.array(place.pop('rotation')).astype(numpy.float32)
+
+ # Rotation matrix
+ if rvalue.shape == (3, 3):
+
+ rmat = rvalue
+
+ # Rotation vector (expected in degree)
+ elif rvalue.shape == (3,):
+
+ rmat = make_rotation_matrix(rvalue[0], rvalue[1], rvalue[2]).astype(numpy.float32)
+
+ else:
+
+ raise ValueError(f'Bad rotation value: {rvalue}')
new_marker = ArUcoMarker.ArUcoMarker(self.dictionary, identifier, self.marker_size)