aboutsummaryrefslogtreecommitdiff
path: root/src/argaze.test/ArGazeProject.py
blob: 8e449bf9025ab7e35bef23101397dd14799a9447 (plain)
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
#!/usr/bin/env python

import unittest
import os

from argaze import ArGazeProject

import numpy

class TestArGazeProjectClass(unittest.TestCase):
    """Test ArGazeProject class."""

    def test_from_json(self):
        """Test ArGazeProject creation from json file."""
        
        # Edit project file path
        current_directory = os.path.dirname(os.path.abspath(__file__))
        json_filepath = os.path.join(current_directory, 'utils/project.json')

        # Load project
        argaze_project = ArGazeProject.ArGazeProject.from_json(json_filepath)

        # Check project meta data
        self.assertEqual(argaze_project.name, "TestProject")

        # Check ArUco camera
        self.assertEqual(argaze_project.aruco_camera.rms, 1.0)
        self.assertIsNone(numpy.testing.assert_array_equal(argaze_project.aruco_camera.dimensions, [1920, 1080]))
        self.assertIsNone(numpy.testing.assert_array_equal(argaze_project.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(argaze_project.aruco_camera.D, [-1.0, -0.5, 0.0, 0.5, 1.0]))

if __name__ == '__main__':

    unittest.main()