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
|
#!/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()
|