aboutsummaryrefslogtreecommitdiff
path: root/src/argaze.test/ArUcoMarkers/ArUcoOpticCalibrator.py
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/ArUcoMarkers/ArUcoOpticCalibrator.py
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/ArUcoMarkers/ArUcoOpticCalibrator.py')
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoOpticCalibrator.py52
1 files changed, 52 insertions, 0 deletions
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