diff options
Diffstat (limited to 'src/argaze.test')
-rw-r--r-- | src/argaze.test/ArGazeScene.py | 59 | ||||
-rw-r--r-- | src/argaze.test/ArScene.py | 59 |
2 files changed, 59 insertions, 59 deletions
diff --git a/src/argaze.test/ArGazeScene.py b/src/argaze.test/ArGazeScene.py deleted file mode 100644 index 4d0b3ae..0000000 --- a/src/argaze.test/ArGazeScene.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python - -import unittest -import os - -from argaze import ArGazeScene - -import numpy - -class TestArGazeSceneClass(unittest.TestCase): - """Test ArGazeScene class.""" - - def test_from_json(self): - """Test ArGazeScene creation from json file.""" - - # Edit scene file path - current_directory = os.path.dirname(os.path.abspath(__file__)) - json_filepath = os.path.join(current_directory, 'utils/scene.json') - - # Load scene - argaze_scene = ArGazeScene.ArGazeScene.from_json(json_filepath) - - # Check scene meta data - self.assertEqual(argaze_scene.name, "TestScene") - self.assertEqual(argaze_scene.aruco_dictionary.name, "DICT_ARUCO_ORIGINAL") - self.assertEqual(argaze_scene.aruco_marker_size, 3.0) - - # Check ArUco camera - self.assertEqual(argaze_scene.aruco_camera.rms, 1.0) - self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_camera.dimensions, [1920, 1080])) - self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.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_scene.aruco_camera.D, [-1.0, -0.5, 0.0, 0.5, 1.0])) - - # Check ArUco tracker - self.assertEqual(argaze_scene.aruco_tracker.tracking_data.cornerRefinementMethod, 3) - self.assertEqual(argaze_scene.aruco_tracker.tracking_data.aprilTagQuadSigma, 2) - self.assertEqual(argaze_scene.aruco_tracker.tracking_data.aprilTagDeglitch, 1) - - # Check ArUco scene - self.assertEqual(argaze_scene.aruco_scene.angle_tolerance, 1.0) - self.assertEqual(argaze_scene.aruco_scene.distance_tolerance, 2.0) - self.assertEqual(len(argaze_scene.aruco_scene.places), 2) - - # Check ArUco scene places - self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_scene.places['A'].translation, [1, 0, 0])) - self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_scene.places['A'].rotation, [0, 0, 0])) - self.assertEqual(argaze_scene.aruco_scene.places['A'].marker.identifier, 0) - - self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_scene.places['B'].translation, [0, 1, 0])) - self.assertIsNone(numpy.testing.assert_array_equal(argaze_scene.aruco_scene.places['B'].rotation, [0, 90, 0])) - self.assertEqual(argaze_scene.aruco_scene.places['B'].marker.identifier, 1) - - # Check AOI scene - self.assertEqual(len(argaze_scene.aoi_scene.items()), 1) - self.assertEqual(argaze_scene.aoi_scene['Test'].size, 4) - -if __name__ == '__main__': - - unittest.main()
\ No newline at end of file diff --git a/src/argaze.test/ArScene.py b/src/argaze.test/ArScene.py new file mode 100644 index 0000000..cfb949b --- /dev/null +++ b/src/argaze.test/ArScene.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python + +import unittest +import os + +from argaze import ArScene + +import numpy + +class TestArSceneClass(unittest.TestCase): + """Test ArScene class.""" + + def test_from_json(self): + """Test ArScene creation from json file.""" + + # Edit scene file path + current_directory = os.path.dirname(os.path.abspath(__file__)) + json_filepath = os.path.join(current_directory, 'utils/scene.json') + + # Load scene + ar_scene = ArScene.ArScene.from_json(json_filepath) + + # Check scene meta data + self.assertEqual(ar_scene.name, "TestScene") + self.assertEqual(ar_scene.aruco_dictionary.name, "DICT_ARUCO_ORIGINAL") + self.assertEqual(ar_scene.aruco_marker_size, 3.0) + + # Check ArUco camera + self.assertEqual(ar_scene.aruco_camera.rms, 1.0) + self.assertIsNone(numpy.testing.assert_array_equal(ar_scene.aruco_camera.dimensions, [1920, 1080])) + self.assertIsNone(numpy.testing.assert_array_equal(ar_scene.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(ar_scene.aruco_camera.D, [-1.0, -0.5, 0.0, 0.5, 1.0])) + + # Check ArUco tracker + self.assertEqual(ar_scene.aruco_tracker.tracking_data.cornerRefinementMethod, 3) + self.assertEqual(ar_scene.aruco_tracker.tracking_data.aprilTagQuadSigma, 2) + self.assertEqual(ar_scene.aruco_tracker.tracking_data.aprilTagDeglitch, 1) + + # Check ArUco scene + self.assertEqual(ar_scene.aruco_scene.angle_tolerance, 1.0) + self.assertEqual(ar_scene.aruco_scene.distance_tolerance, 2.0) + self.assertEqual(len(ar_scene.aruco_scene.places), 2) + + # Check ArUco scene places + self.assertIsNone(numpy.testing.assert_array_equal(ar_scene.aruco_scene.places['A'].translation, [1, 0, 0])) + self.assertIsNone(numpy.testing.assert_array_equal(ar_scene.aruco_scene.places['A'].rotation, [0, 0, 0])) + self.assertEqual(ar_scene.aruco_scene.places['A'].marker.identifier, 0) + + self.assertIsNone(numpy.testing.assert_array_equal(ar_scene.aruco_scene.places['B'].translation, [0, 1, 0])) + self.assertIsNone(numpy.testing.assert_array_equal(ar_scene.aruco_scene.places['B'].rotation, [0, 90, 0])) + self.assertEqual(ar_scene.aruco_scene.places['B'].marker.identifier, 1) + + # Check AOI scene + self.assertEqual(len(ar_scene.aoi_scene.items()), 1) + self.assertEqual(ar_scene.aoi_scene['Test'].size, 4) + +if __name__ == '__main__': + + unittest.main()
\ No newline at end of file |