Preferred aruco marker Python

Viewed 49

Is it possible to recognize aruco markers in a certain order (or) only recognize single ones?

enter image description here enter image description here

What I would like to achieve:

  • Recognize the marker via webcam
  • Draw something with polylines between three markers but since the markers are recognized clockwise the coordinates change and the line jumps back and forth.

My Solution:

  • Use arucos from different dictionaries and recognize each one individually and draw the desired shape.
  • I tried to recognize the arucos by their id but it didn't work.
  • I don't need any code or solution if someone could just point me to something where I can find the information I need

Thanks in advance :)

    import cv2 as cv
    import numpy as np

    cap  = cv.VideoCapture(1)


    aruco_dic = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)



    while True:
        ret ,frame = cap.read()


        fr_gr = cv.cvtColor(frame,cv.COLOR_BGRA2GRAY)


        corner, ids, _ = cv.aruco.detectMarkers(fr_gr,aruco_dic,ids=2)

        lis =[ids,corner]
        try:
            if lis[0][1] == 2:
                cnt = lis[1][1]

                x, y, h, w = cv.boundingRect(cnt)
                cv.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)

            elif lis[0][0] == 2:
                cnt = lis[1][0]
                x, y, h, w = cv.boundingRect(cnt)
                cv.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
            else:pass


        except:pass

        cv.imshow("bild1", frame)

        if cv.waitKey(1) == ord("q"):
            break
    cap.release()
    cv.destroyAllWindows()
0 Answers
Related