aboutsummaryrefslogtreecommitdiff
path: root/src/argaze.test
diff options
context:
space:
mode:
authorThéo de la Hogue2023-06-14 11:36:40 +0200
committerThéo de la Hogue2023-06-14 11:36:40 +0200
commit4a5c7ad8bf29afc5af893c524e5753de302873b7 (patch)
tree3bcfc09e13dea8786d82c5e4f90f231ec945bdda /src/argaze.test
parenta292d09c2a95237429bd740075f396e8ca74b5c9 (diff)
downloadargaze-4a5c7ad8bf29afc5af893c524e5753de302873b7.zip
argaze-4a5c7ad8bf29afc5af893c524e5753de302873b7.tar.gz
argaze-4a5c7ad8bf29afc5af893c524e5753de302873b7.tar.bz2
argaze-4a5c7ad8bf29afc5af893c524e5753de302873b7.tar.xz
Renaming ArUcoCamera into ArUcoOpticCalibrator. Using OpticParameters class to handle K and D parameters.
Diffstat (limited to 'src/argaze.test')
-rw-r--r--src/argaze.test/ArFeatures.py10
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoCamera.py52
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoDetector.py8
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoOpticCalibrator.py52
-rw-r--r--src/argaze.test/ArUcoMarkers/utils/detector.json2
-rw-r--r--src/argaze.test/ArUcoMarkers/utils/optic_parameters.json (renamed from src/argaze.test/ArUcoMarkers/utils/camera.json)0
-rw-r--r--src/argaze.test/utils/environment.json2
7 files changed, 63 insertions, 63 deletions
diff --git a/src/argaze.test/ArFeatures.py b/src/argaze.test/ArFeatures.py
index 3f7972d..5da63d1 100644
--- a/src/argaze.test/ArFeatures.py
+++ b/src/argaze.test/ArFeatures.py
@@ -37,11 +37,11 @@ class TestArEnvironmentClass(unittest.TestCase):
self.assertEqual(ar_environment.aruco_detector.parameters.aprilTagQuadSigma, 2)
self.assertEqual(ar_environment.aruco_detector.parameters.aprilTagDeglitch, 1)
- # Check ArUco detector camera
- self.assertEqual(ar_environment.aruco_detector.camera.rms, 1.0)
- self.assertIsNone(numpy.testing.assert_array_equal(ar_environment.aruco_detector.camera.dimensions, [1920, 1080]))
- self.assertIsNone(numpy.testing.assert_array_equal(ar_environment.aruco_detector.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(ar_environment.aruco_detector.camera.D, [-1.0, -0.5, 0.0, 0.5, 1.0]))
+ # Check ArUco detector optic parameters
+ self.assertEqual(ar_environment.aruco_detector.optic_parameters.rms, 1.0)
+ self.assertIsNone(numpy.testing.assert_array_equal(ar_environment.aruco_detector.optic_parameters.dimensions, [1920, 1080]))
+ self.assertIsNone(numpy.testing.assert_array_equal(ar_environment.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(ar_environment.aruco_detector.optic_parameters.D, [-1.0, -0.5, 0.0, 0.5, 1.0]))
# Check environment scenes
self.assertEqual(len(ar_environment.scenes), 2)
diff --git a/src/argaze.test/ArUcoMarkers/ArUcoCamera.py b/src/argaze.test/ArUcoMarkers/ArUcoCamera.py
deleted file mode 100644
index 7a53070..0000000
--- a/src/argaze.test/ArUcoMarkers/ArUcoCamera.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env python
-
-""" """
-
-__author__ = "Théo de la Hogue"
-__credits__ = []
-__copyright__ = "Copyright 2023, Ecole Nationale de l'Aviation Civile (ENAC)"
-__license__ = "BSD"
-
-import unittest
-import os
-
-from argaze.ArUcoMarkers import ArUcoCamera
-
-import numpy
-
-class TestArUcoCameraClass(unittest.TestCase):
- """Test ArUcoCamera class."""
-
- def test_new(self):
- """Test ArUcoCamera creation."""
-
- # Check defaut camera creation
- aruco_camera = ArUcoCamera.ArUcoCamera()
-
- # Check ArUco camera
- self.assertEqual(aruco_camera.rms, 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))
-
- def test_from_json(self):
-
- # Edit camera file path
- current_directory = os.path.dirname(os.path.abspath(__file__))
- json_filepath = os.path.join(current_directory, 'utils/camera.json')
-
- # Load camera calibration
- aruco_camera = ArUcoCamera.ArUcoCamera.from_json(json_filepath)
-
- # Check ArUco camera
- self.assertEqual(aruco_camera.rms, 1.0)
- 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]))
-
-if __name__ == '__main__':
-
- unittest.main() \ No newline at end of file
diff --git a/src/argaze.test/ArUcoMarkers/ArUcoDetector.py b/src/argaze.test/ArUcoMarkers/ArUcoDetector.py
index cd7c90c..750aaa5 100644
--- a/src/argaze.test/ArUcoMarkers/ArUcoDetector.py
+++ b/src/argaze.test/ArUcoMarkers/ArUcoDetector.py
@@ -11,7 +11,7 @@ import unittest
import os
import math
-from argaze.ArUcoMarkers import ArUcoMarkersDictionary, ArUcoCamera, ArUcoDetector, ArUcoBoard
+from argaze.ArUcoMarkers import ArUcoMarkersDictionary, ArUcoOpticCalibrator, ArUcoDetector, ArUcoBoard
import cv2 as cv
import numpy
@@ -50,7 +50,7 @@ class TestArUcoDetectorClass(unittest.TestCase):
# Check ArUcoDetector creation
self.assertEqual(aruco_detector.dictionary.name, 'DICT_ARUCO_ORIGINAL')
self.assertEqual(aruco_detector.marker_size, 3)
- self.assertIsNone(numpy.testing.assert_array_equal(aruco_detector.camera.dimensions, [0, 0]))
+ self.assertIsNone(numpy.testing.assert_array_equal(aruco_detector.optic_parameters.dimensions, [0, 0]))
self.assertEqual(aruco_detector.detected_markers_number, 0)
self.assertEqual(aruco_detector.detected_markers, {})
@@ -60,7 +60,7 @@ class TestArUcoDetectorClass(unittest.TestCase):
# Check ArUcoDetector creation
self.assertEqual(aruco_detector.dictionary.name, 'DICT_APRILTAG_16h5')
self.assertEqual(aruco_detector.marker_size, 5.2)
- self.assertIsNone(numpy.testing.assert_array_equal(aruco_detector.camera.dimensions, [0, 0]))
+ self.assertIsNone(numpy.testing.assert_array_equal(aruco_detector.optic_parameters.dimensions, [0, 0]))
self.assertEqual(aruco_detector.detected_markers_number, 0)
self.assertEqual(aruco_detector.detected_markers, {})
@@ -77,7 +77,7 @@ class TestArUcoDetectorClass(unittest.TestCase):
# Check ArUcoDetector creation
self.assertEqual(aruco_detector.dictionary.name, 'DICT_ARUCO_ORIGINAL')
self.assertEqual(aruco_detector.marker_size, 3)
- self.assertIsNone(numpy.testing.assert_array_equal(aruco_detector.camera.dimensions, [1920, 1080]))
+ self.assertIsNone(numpy.testing.assert_array_equal(aruco_detector.optic_parameters.dimensions, [1920, 1080]))
self.assertEqual(aruco_detector.parameters.cornerRefinementMethod, 3)
self.assertEqual(aruco_detector.parameters.aprilTagQuadSigma, 2)
self.assertEqual(aruco_detector.parameters.aprilTagDeglitch, 1)
diff --git a/src/argaze.test/ArUcoMarkers/ArUcoOpticCalibrator.py b/src/argaze.test/ArUcoMarkers/ArUcoOpticCalibrator.py
new file mode 100644
index 0000000..45b7669
--- /dev/null
+++ b/src/argaze.test/ArUcoMarkers/ArUcoOpticCalibrator.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+
+""" """
+
+__author__ = "Théo de la Hogue"
+__credits__ = []
+__copyright__ = "Copyright 2023, Ecole Nationale de l'Aviation Civile (ENAC)"
+__license__ = "BSD"
+
+import unittest
+import os
+
+from argaze.ArUcoMarkers import ArUcoOpticCalibrator
+
+import numpy
+
+class TestOpticParametersClass(unittest.TestCase):
+ """Test OpticParameters class."""
+
+ def test_new(self):
+ """Test OpticParameters creation."""
+
+ # Check defaut optic parameters creation
+ optic_parameters = ArUcoOpticCalibrator.OpticParameters()
+
+ # Check ArUco optic parameters
+ self.assertEqual(optic_parameters.rms, 0.0)
+
+ #self.assertEqual(type(optic_parameters.K), numpy.array)
+
+ self.assertIsNone(numpy.testing.assert_array_equal(optic_parameters.dimensions, [0, 0]))
+ self.assertIsNone(numpy.testing.assert_array_equal(optic_parameters.K, ArUcoOpticCalibrator.K0))
+ self.assertIsNone(numpy.testing.assert_array_equal(optic_parameters.D, ArUcoOpticCalibrator.D0))
+
+ def test_from_json(self):
+
+ # Edit optic parameters file path
+ current_directory = os.path.dirname(os.path.abspath(__file__))
+ json_filepath = os.path.join(current_directory, 'utils/optic_parameters.json')
+
+ # Load optic parameters
+ optic_parameters = ArUcoOpticCalibrator.OpticParameters.from_json(json_filepath)
+
+ # Check ArUco camera
+ self.assertEqual(optic_parameters.rms, 1.0)
+ self.assertIsNone(numpy.testing.assert_array_equal(optic_parameters.dimensions, [1920, 1080]))
+ self.assertIsNone(numpy.testing.assert_array_equal(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(optic_parameters.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/ArUcoMarkers/utils/detector.json b/src/argaze.test/ArUcoMarkers/utils/detector.json
index a239bf8..8aada6d 100644
--- a/src/argaze.test/ArUcoMarkers/utils/detector.json
+++ b/src/argaze.test/ArUcoMarkers/utils/detector.json
@@ -3,7 +3,7 @@
"name": "DICT_ARUCO_ORIGINAL"
},
"marker_size": 3.0,
- "camera": {
+ "optic_parameters": {
"rms": 1.0,
"dimensions": [
1920,
diff --git a/src/argaze.test/ArUcoMarkers/utils/camera.json b/src/argaze.test/ArUcoMarkers/utils/optic_parameters.json
index 988731c..988731c 100644
--- a/src/argaze.test/ArUcoMarkers/utils/camera.json
+++ b/src/argaze.test/ArUcoMarkers/utils/optic_parameters.json
diff --git a/src/argaze.test/utils/environment.json b/src/argaze.test/utils/environment.json
index 57d04cf..df1c771 100644
--- a/src/argaze.test/utils/environment.json
+++ b/src/argaze.test/utils/environment.json
@@ -5,7 +5,7 @@
"name": "DICT_ARUCO_ORIGINAL"
},
"marker_size": 3.0,
- "camera": {
+ "optic_parameters": {
"rms": 1.0,
"dimensions": [
1920,