# How to create a customized non-square aruco board

0

I am trying to find information and examples on how to create a custom aruco board. In my case, I need to place several markers on the surface of an object to perform pose detection.

In this case, as the object is relatively small, the markers to be used must be small and, in this way, with only one marker I get too much error in the X or Y rotation.

Here are the topic created on the problem that I have:

In case you need more extra information, dont hesitate to ask it!

`cv.aruco.Board_create(boardpts, arucodict, ids)`

boardpts needs to be (N,4,3)

N for the number of markers
4 for the four corners of one marker
3 for the xyz of that corner

arucodict could be `getPredefinedDictionary(cv.aruco.DICT_4X4_1000)`

ids is an array of just the IDs

so what you might wanna do is define a list of markers. id, size, and markerâ€™s pose in â€śboard spaceâ€ť (marker to board).

for that itâ€™s useful to have functions that give you primitive 4x4 transformations like translation, rotation, scalingâ€¦ and then you compose them with `@` (matrix multiplication).

then you can generate the corners of each marker (top left is -x+y, top right +x+y, bottom right +x-y, bottom left -x-y), scale them to size, transform to board space, and keep around. thatâ€™s another matrix mul, applying the transformation to these points so theyâ€™re now in board space.

thatâ€™s the array of corners for the Board_create call

for `estimatePoseBoard`, you dump all your found markers in there (ids and corners) along with the desired board object, and it will figure out what belongs, and what the boardâ€™s pose should be.

I have done this prototype of code, I have not test it because Iâ€™m not in the laboratory but I will test it the next week. Could you see something wrong there? Do you think this will work?

``````def DetectMarkerBoard(self):
"""
Funcion que permite detectar el "tablero" de marcadores ArUco tras obtener los pareametros asociados
a la camara
:return: vector de desalineamientos [X,Y,Z,Rx,Ry,Rz] que determinan la pose del SIROM (TABLERO)
respecto de la camara
"""
cam=cv2.VideoCapture(self.CameraID,cv2.CAP_DSHOW)
#Configuro la camara para la captura del objetivo
cam.set(3, 1280)  # width --> Anchura
cam.set(4, 720)  # height--> altura
cam.set(39, 0) #Autofocus OFF
start=0
stop=0
ArucoDict = cv2.aruco.Dictionary_get(self.ArucoDict)
ArucoParams = cv2.aruco.DetectorParameters_create()
ArucoParams.cornerRefinementMethod = 1
rvec=None
tvec=None
while True:
if ret != True:
print("NO HA SIDO POSIBLE RECIBIR NINGUN FRAME DE LA CAMARA")
break
else:
#Convierto las esquinas a X,Y,Z
new_corners = np.zeros(shape=(len(esquinas), 4, 3))
for cnt, corner in enumerate(esquinas):
new_corners[cnt, :, :-1] = corner
# Creo mi board compuesto de dos marcadores
ArucoBoard=cv2.aruco.Board_create(new_corners.astype(np.float32), self.ArucoDict, ids)
#Detecto el board compuesto de los dos aruco
ret,rvec_Aruco_respect_Camara, tvec_Aruco_respect_Camara=cv2.aruco.estimatePoseBoard(esquinas,ids,ArucoBoard,self.CamMtx,self.CamDst,rvec,tvec)
#Calculo FPS de la camara
stop=time.time()
self.FPS=1/(stop-start)
start=stop
fps="FPS: "+str(int(self.FPS))
if ret>0:
frame=cv2.aruco.drawAxis(Frame_procesado, self.CamMtx, self.CamDst, rvec_Aruco_respect_Camara, tvec_Aruco_respect_Camara, 0.05)
cv2.putText(frame, fps, (3, 25), cv2.FONT_HERSHEY_SIMPLEX, 1, (100, 255, 0), 3, cv2.LINE_AA)
cv2.waitKey(1)
else:
#Calculo FPS de la camara, dibujo los ejes de coordenadas, el nÂş de FPS...
stop = time.time()
self.FPS = 1 / (stop - start)
start = stop
fps = "FPS: " + str(int(self.FPS))
cv2.putText(frame, fps, (3, 25), cv2.FONT_HERSHEY_SIMPLEX, 1, (100, 255, 0), 3, cv2.LINE_AA)
cv2.waitKey(1)
print("NO SE HA DETECTADO NINGUN SIROM")
``````

It must be said that I calculated the `aruco board` in each iteration because the object which have the markers will be moving during the test, so I need to know the aruco points for each iteration and also, calculate the board in each iteration.

that wonâ€™t work and it doesnâ€™t make sense.

the definition of a â€śboardâ€ť requires 3D points, all in â€śboard spaceâ€ť. you donâ€™t have 3D points there. you have 2D points, in screen space.

Iâ€™m not sure you understand what aruco â€śboardâ€ť objects are meant for.

besides that, I donâ€™t speak the language you use for your identifiers. that makes following the code less convenient.

tutorial for this stuff: OpenCV: Detection of ArUco Boards

the API docs themselves arenâ€™t clear on some details.

1 Like

Of course, you are right.

So from what I understand, I must define the position of the marker in the space of the board itself. That is, in my case, I will use three markers located in the center of the sides of an equilateral triangle. In this way, the markers will be in the same plane (Z=0).

My question now is, with respect to what point should I define the position of the upper left corner of each of the markers that make up my board?Could I do it from the center of the equilateral triangle? In this way, the reference system of my board would be the center of the equilateral triangle?