diff --git a/charuco.py b/charuco.py new file mode 100644 index 0000000..01c7e48 --- /dev/null +++ b/charuco.py @@ -0,0 +1,26 @@ +import os +import numpy as np +import cv2 + +# ------------------------------ +# ENTER YOUR PARAMETERS HERE: +ARUCO_DICT = cv2.aruco.DICT_6X6_250 +SQUARES_VERTICALLY = 6 +SQUARES_HORIZONTALLY = 9 +SQUARE_LENGTH = 1 +MARKER_LENGTH = 0.6875 +LENGTH_PX = 640 # total length of the page in pixels +MARGIN_PX = 20 # size of the margin in pixels +SAVE_NAME = 'ChArUco_Marker.png' +# ------------------------------ + +def create_and_save_new_board(): + dictionary = cv2.aruco.getPredefinedDictionary(ARUCO_DICT) + board = cv2.aruco.CharucoBoard((SQUARES_VERTICALLY, SQUARES_HORIZONTALLY), SQUARE_LENGTH, MARKER_LENGTH, dictionary) + size_ratio = SQUARES_HORIZONTALLY / SQUARES_VERTICALLY + img = cv2.aruco.CharucoBoard.generateImage(board, (LENGTH_PX, int(LENGTH_PX*size_ratio)), marginSize=MARGIN_PX) + cv2.imshow("img", img) + cv2.waitKey(2000) + cv2.imwrite(SAVE_NAME, img) + +create_and_save_new_board() \ No newline at end of file