0

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()
Shkolo
  • 1
  • 2
  • 1
    [mre] please. there ought to be no jumping. markers, if they decoded okay (have their ID decoded), have orientation, and the first point, in OpenCV's aruco module, is always the top left corner. -- if you need the _markers_ sorted, not their corners, then you should _sort_ them. markers have IDs. you get a _set_ of markers detected. you are responsible for using their identification number. – Christoph Rackwitz Sep 06 '22 at 18:09
  • thanks for the answer The three markers move in the video clockwise and once in the other direction thereby always a V should arise that does not change only moves along So I can sort the xy coordinates with the id? So is it possible to identify the coordinates by the id? – Shkolo Sep 08 '22 at 06:30
  • this works but i believe there is a much better solution – Shkolo Sep 13 '22 at 20:01
  • in the image there are two markers from the same dictonary but it only "recognizes" the one with id 2 – Shkolo Sep 13 '22 at 20:06
  • `lis =[ids,corner]` is just pointless. `except: pass` is a mortal sin. `x, y, h, w`... first width, then height. -- ah, you stopped after _detecting_ them. you could just calculate the center of the screen-space corner points. that's done using the average. or you could recover their poses, so you can get their 3D positions. -- "but it didn't work." is a lousy description of what did happen and why that failed to meet your expectations, and what those were. – Christoph Rackwitz Sep 14 '22 at 00:07

0 Answers0