1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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()
|