test_aruco.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python
  2. # Python 2/3 compatibility
  3. from __future__ import print_function
  4. import os, numpy as np
  5. import cv2 as cv
  6. from tests_common import NewOpenCVTests
  7. class aruco_test(NewOpenCVTests):
  8. def test_idsAccessibility(self):
  9. ids = np.arange(17)
  10. rev_ids = ids[::-1]
  11. aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_5X5_250)
  12. board = cv.aruco.CharucoBoard_create(7, 5, 1, 0.5, aruco_dict)
  13. np.testing.assert_array_equal(board.ids.squeeze(), ids)
  14. board.ids = rev_ids
  15. np.testing.assert_array_equal(board.ids.squeeze(), rev_ids)
  16. board.setIds(ids)
  17. np.testing.assert_array_equal(board.ids.squeeze(), ids)
  18. with self.assertRaises(cv.error):
  19. board.setIds(np.array([0]))
  20. def test_drawCharucoDiamond(self):
  21. aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
  22. img = cv.aruco.drawCharucoDiamond(aruco_dict, np.array([0, 1, 2, 3]), 100, 80)
  23. self.assertTrue(img is not None)
  24. if __name__ == '__main__':
  25. NewOpenCVTests.bootstrap()