diff options
Diffstat (limited to 'src/argaze.test/ArUcoMarker/ArUcoOpticCalibrator.py')
-rw-r--r-- | src/argaze.test/ArUcoMarker/ArUcoOpticCalibrator.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/argaze.test/ArUcoMarker/ArUcoOpticCalibrator.py b/src/argaze.test/ArUcoMarker/ArUcoOpticCalibrator.py new file mode 100644 index 0000000..d019a5d --- /dev/null +++ b/src/argaze.test/ArUcoMarker/ArUcoOpticCalibrator.py @@ -0,0 +1,61 @@ +""" + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +You should have received a copy of the GNU General Public License along with +this program. If not, see <https://www.gnu.org/licenses/>. +""" + +__author__ = "Théo de la Hogue" +__credits__ = [] +__copyright__ = "Copyright 2023, Ecole Nationale de l'Aviation Civile (ENAC)" +__license__ = "GPLv3" + +import unittest +import os + +from argaze.ArUcoMarker 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 |