When I generate a CharucoBoard. How do you find the positions of the Aruco Markers on the generated image?
Using getObjPoints does not work at all.
import sys, getopt
import time
import numpy as np
import cv2
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib as mpl
def main():
width = 1920
height = 1080
box_size = 200
box_width_num = int(width/box_size)
box_height_num = int(height/box_size)
aruco_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_6X6_50)
board = cv2.aruco.CharucoBoard((box_width_num, box_height_num), 2.0, 1.0, aruco_dict)
img = board.generateImage( (width, height) )
#print(board.getIds())
squares = board.getObjPoints()
img = cv2.cvtColor(img,cv2.COLOR_GRAY2RGB)
for i in range(len(squares)):
square = squares[i]
minimum = (np.min(square, axis=0)*box_size*0.5).astype(int)
maximum = (np.max(square, axis=0)*box_size*0.5).astype(int)
img = cv2.rectangle(img, (minimum[0] , minimum[1] ), ( maximum[0] , maximum[1] ), (0, 255, 0), 4)
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.imshow(img, interpolation = "nearest")
ax.axis("off")
plt.show()
if __name__ == "__main__":
main()