aboutsummaryrefslogtreecommitdiff
path: root/src/argaze.test
diff options
context:
space:
mode:
Diffstat (limited to 'src/argaze.test')
-rw-r--r--src/argaze.test/ArGazeProject.py34
-rw-r--r--src/argaze.test/ArGazeScene.py59
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoCamera.py7
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoTracker.py23
-rw-r--r--src/argaze.test/ArUcoMarkers/utils/tracker.json5
-rw-r--r--src/argaze.test/utils/aoi.obj7
-rw-r--r--src/argaze.test/utils/project.json34
-rw-r--r--src/argaze.test/utils/scene.json58
8 files changed, 157 insertions, 70 deletions
diff --git a/src/argaze.test/ArGazeProject.py b/src/argaze.test/ArGazeProject.py
deleted file mode 100644
index 8e449bf..0000000
--- a/src/argaze.test/ArGazeProject.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env python
-
-import unittest
-import os
-
-from argaze import ArGazeProject
-
-import numpy
-
-class TestArGazeProjectClass(unittest.TestCase):
- """Test ArGazeProject class."""
-
- def test_from_json(self):
- """Test ArGazeProject creation from json file."""
-
- # Edit project file path
- current_directory = os.path.dirname(os.path.abspath(__file__))
- json_filepath = os.path.join(current_directory, 'utils/project.json')
-
- # Load project
- argaze_project = ArGazeProject.ArGazeProject.from_json(json_filepath)
-
- # Check project meta data
- self.assertEqual(argaze_project.name, "TestProject")
-
- # Check ArUco camera
- self.assertEqual(argaze_project.aruco_camera.rms, 1.0)
- self.assertIsNone(numpy.testing.assert_array_equal(argaze_project.aruco_camera.dimensions, [1920, 1080]))
- self.assertIsNone(numpy.testing.assert_array_equal(argaze_project.aruco_camera.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(argaze_project.aruco_camera.D, [-1.0, -0.5, 0.0, 0.5, 1.0]))
-
-if __name__ == '__main__':
-
- unittest.main() \ No newline at end of file
diff --git a/src/argaze.test/ArGazeScene.py b/src/argaze.test/ArGazeScene.py
new file mode 100644
index 0000000..4d0b3ae
--- /dev/null
+++ b/src/argaze.test/ArGazeScene.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+
+import unittest
+import os
+
+from argaze import ArGazeScene
+
+import numpy
+
+class TestArGazeSceneClass(unittest.TestCase):
+ """Test ArGazeScene class."""
+
+ def test_from_json(self):
+ """Test ArGazeScene creation from json file."""
+
+ # Edit scene file path
+ current_directory = os.path.dirname(os.path.abspath(__file__))
+ json_filepath = os.path.join(current_directory, 'utils/scene.json')
+
+ # Load scene
+ argaze_scene = ArGazeScene.ArGazeScene.from_json(json_filepath)
+
+ # Check scene meta data
+ self.assertEqual(argaze_scene.name, "TestScene")
+ self.assertEqual(argaze_scene.aruco_dictionary.name, "DICT_ARUCO_ORIGINAL")
+ self.assertEqual(argaze_scene.aruco_marker_size, 3.0)
+
+ # Check ArUco camera
+ self.assertEqual(argaze_scene.aruco_camera.rms, 1.0)
+ self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_camera.dimensions, [1920, 1080]))
+ self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_camera.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(argaze_scene.aruco_camera.D, [-1.0, -0.5, 0.0, 0.5, 1.0]))
+
+ # Check ArUco tracker
+ self.assertEqual(argaze_scene.aruco_tracker.tracking_data.cornerRefinementMethod, 3)
+ self.assertEqual(argaze_scene.aruco_tracker.tracking_data.aprilTagQuadSigma, 2)
+ self.assertEqual(argaze_scene.aruco_tracker.tracking_data.aprilTagDeglitch, 1)
+
+ # Check ArUco scene
+ self.assertEqual(argaze_scene.aruco_scene.angle_tolerance, 1.0)
+ self.assertEqual(argaze_scene.aruco_scene.distance_tolerance, 2.0)
+ self.assertEqual(len(argaze_scene.aruco_scene.places), 2)
+
+ # Check ArUco scene places
+ self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_scene.places['A'].translation, [1, 0, 0]))
+ self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_scene.places['A'].rotation, [0, 0, 0]))
+ self.assertEqual(argaze_scene.aruco_scene.places['A'].marker.identifier, 0)
+
+ self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_scene.places['B'].translation, [0, 1, 0]))
+ self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_scene.places['B'].rotation, [0, 90, 0]))
+ self.assertEqual(argaze_scene.aruco_scene.places['B'].marker.identifier, 1)
+
+ # Check AOI scene
+ self.assertEqual(len(argaze_scene.aoi_scene.items()), 1)
+ self.assertEqual(argaze_scene.aoi_scene['Test'].size, 4)
+
+if __name__ == '__main__':
+
+ unittest.main() \ No newline at end of file
diff --git a/src/argaze.test/ArUcoMarkers/ArUcoCamera.py b/src/argaze.test/ArUcoMarkers/ArUcoCamera.py
index 7e50e8c..ef78b04 100644
--- a/src/argaze.test/ArUcoMarkers/ArUcoCamera.py
+++ b/src/argaze.test/ArUcoMarkers/ArUcoCamera.py
@@ -18,7 +18,10 @@ class TestArUcoCameraClass(unittest.TestCase):
# Check ArUco camera
self.assertEqual(aruco_camera.rms, 0.0)
- self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.dimensions, numpy.array([0, 0])))
+
+ #self.assertEqual(type(aruco_camera.K), numpy.array)
+
+ self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.dimensions, [0, 0]))
self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.K, ArUcoCamera.K0))
self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.D, ArUcoCamera.D0))
@@ -33,7 +36,7 @@ class TestArUcoCameraClass(unittest.TestCase):
# Check ArUco camera
self.assertEqual(aruco_camera.rms, 1.0)
- self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.dimensions, numpy.array([1920, 1080])))
+ self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.dimensions, [1920, 1080]))
self.assertIsNone(numpy.testing.assert_array_equal(aruco_camera.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.D, [-1.0, -0.5, 0.0, 0.5, 1.0]))
diff --git a/src/argaze.test/ArUcoMarkers/ArUcoTracker.py b/src/argaze.test/ArUcoMarkers/ArUcoTracker.py
index acc0000..87373ea 100644
--- a/src/argaze.test/ArUcoMarkers/ArUcoTracker.py
+++ b/src/argaze.test/ArUcoMarkers/ArUcoTracker.py
@@ -9,6 +9,29 @@ from argaze.ArUcoMarkers import ArUcoMarkersDictionary, ArUcoCamera, ArUcoTracke
import cv2 as cv
import numpy
+class TestTrackingDataClass(unittest.TestCase):
+ """Test TrackingData class."""
+
+ def test_from_json(self):
+ """Test TrackingData creation from json file."""
+
+ # Edit traking data file path
+ current_directory = os.path.dirname(os.path.abspath(__file__))
+ json_filepath = os.path.join(current_directory, 'utils/tracker.json')
+
+ # Load project
+ tracking_data = ArUcoTracker.TrackingData.from_json(json_filepath)
+
+ # Check data
+ self.assertEqual(tracking_data.cornerRefinementMethod, 3)
+ self.assertEqual(tracking_data.aprilTagQuadSigma, 2)
+ self.assertEqual(tracking_data.aprilTagDeglitch, 1)
+
+ # Check bad data access fails
+ with self.assertRaises(AttributeError):
+
+ tracking_data.unknown_data = 1
+
class TestArUcoTrackerClass(unittest.TestCase):
"""Test ArUcoTracker class."""
diff --git a/src/argaze.test/ArUcoMarkers/utils/tracker.json b/src/argaze.test/ArUcoMarkers/utils/tracker.json
new file mode 100644
index 0000000..d26a3fa
--- /dev/null
+++ b/src/argaze.test/ArUcoMarkers/utils/tracker.json
@@ -0,0 +1,5 @@
+{
+ "cornerRefinementMethod": 3,
+ "aprilTagQuadSigma": 2,
+ "aprilTagDeglitch": 1
+} \ No newline at end of file
diff --git a/src/argaze.test/utils/aoi.obj b/src/argaze.test/utils/aoi.obj
new file mode 100644
index 0000000..ed4554f
--- /dev/null
+++ b/src/argaze.test/utils/aoi.obj
@@ -0,0 +1,7 @@
+o Test
+v 0.000000 0.000000 0.000000
+v 1.000000 0.000000 0.000000
+v 0.000000 1.000000 0.000000
+v 1.000000 1.000000 0.000000
+s off
+f 1 2 4 3
diff --git a/src/argaze.test/utils/project.json b/src/argaze.test/utils/project.json
deleted file mode 100644
index e2812f2..0000000
--- a/src/argaze.test/utils/project.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "name": "TestProject",
- "aruco_camera": {
- "rms": 1.0,
- "dimensions": [
- 1920,
- 1080
- ],
- "K": [
- [
- 1.0,
- 0.0,
- 1.0
- ],
- [
- 0.0,
- 1.0,
- 1.0
- ],
- [
- 0.0,
- 0.0,
- 1.0
- ]
- ],
- "D": [
- -1.0,
- -0.5,
- 0.0,
- 0.5,
- 1.0
- ]
- }
-} \ No newline at end of file
diff --git a/src/argaze.test/utils/scene.json b/src/argaze.test/utils/scene.json
new file mode 100644
index 0000000..1f80eac
--- /dev/null
+++ b/src/argaze.test/utils/scene.json
@@ -0,0 +1,58 @@
+{
+ "name": "TestScene",
+ "aruco_dictionary": "DICT_ARUCO_ORIGINAL",
+ "aruco_marker_size": 3.0,
+ "aruco_camera": {
+ "rms": 1.0,
+ "dimensions": [
+ 1920,
+ 1080
+ ],
+ "K": [
+ [
+ 1.0,
+ 0.0,
+ 1.0
+ ],
+ [
+ 0.0,
+ 1.0,
+ 1.0
+ ],
+ [
+ 0.0,
+ 0.0,
+ 1.0
+ ]
+ ],
+ "D": [
+ -1.0,
+ -0.5,
+ 0.0,
+ 0.5,
+ 1.0
+ ]
+ },
+ "aruco_tracker": {
+ "cornerRefinementMethod": 3,
+ "aprilTagQuadSigma": 2,
+ "aprilTagDeglitch": 1
+ },
+ "aruco_scene": {
+ "places": {
+ "A": {
+ "translation": [1, 0, 0],
+ "rotation": [0, 0, 0],
+ "marker": 0
+ },
+ "B": {
+ "translation": [0, 1, 0],
+ "rotation": [0, 90, 0],
+ "marker": 1
+ }
+ },
+ "angle_tolerance": 1.0,
+ "distance_tolerance": 2.0
+ },
+ "aoi_scene": "aoi.obj"
+} \ No newline at end of file