Skip to content

Commit

Permalink
added class for charuco
Browse files Browse the repository at this point in the history
  • Loading branch information
nandikakohli committed Nov 9, 2023
1 parent 721e055 commit 124c3b2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions charuco.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 124c3b2

Please sign in to comment.