Inconsistent orientation of detected/generated ArUco and AprilTags

Aperta
#1,195 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
opencv, python

Direzione di ricerca

Inizia con la riproduzione Python fornita usando ArucoDetector.detectMarkers e generateImageMarker per i dizionari AprilTag e ArUco. Analizza come ciascun dizionario definisce l’ordinamento degli angoli e l’orientamento dei marker generati; il lavoro è completato quando il rilevamento e la generazione usano un orientamento coerente per entrambe le famiglie di marker e la riproduzione conferma l’ordinamento corretto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

ArUco and AprilTag detection both uses a clockwise orientation, however, AprilTag corners start with bottom right while ArUco starts with upper left. See the example below:

Image Image

Code:

import cv2


def draw_markers_with_corners(img, corners):
    for i, marker_corners in enumerate(corners):
        # Get the corners of the marker
        corner_points = marker_corners.reshape((4, 2))
        corner_points = corner_points.astype(int)

        # Draw each corner with its ordinal position
        for j, corner in enumerate(corner_points):
            # Draw corner point
            cv2.circle(img, tuple(corner), 5, (0, 0, 255), -1)
            # Label the corner with its ordinal position (0, 1, 2, 3)
            cv2.putText(
                img,
                str(j),
                (corner[0] + 10, corner[1] + 10),
                cv2.FONT_HERSHEY_SIMPLEX,
                0.5,
                (255, 0, 0),
                2,
            )

    return img


img = cv2.imread("markers.jpeg")

parameters = cv2.aruco.DetectorParameters()

april_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_APRILTAG_36h11)
april_detector = cv2.aruco.ArucoDetector(april_dict, parameters)
aruco_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_4X4_250)
aruco_detector = cv2.aruco.ArucoDetector(aruco_dict, parameters)

img_marked = img.copy()
april_corners, _, _ = april_detector.detectMarkers(img)
img_marked = draw_markers_with_corners(img_marked, april_corners)

aruco_corners, _, _ = aruco_detector.detectMarkers(img)
img_marked = draw_markers_with_corners(img_marked, aruco_corners)

cv2.imwrite("markers_detected.jpeg", img_marked)

The same issue persists (likely due to pre-defined dictionary configurations) for generation:

The generated AprilTag 36h11 - 0 (wrong orientation, see above)
Image

The generated ArUco 4x4_250 - 0 (correct orientation, see above)
Image

Code:

import cv2

april_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_APRILTAG_36h11)
aruco_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_4X4_250)

img = cv2.aruco.generateImageMarker(aruco_dict, 0, 200, borderBits=1)
cv2.imwrite("aruco.png", img)

img = cv2.aruco.generateImageMarker(april_dict, 0, 200, borderBits=1)
cv2.imwrite("april.png", img)
Lingua principale
Python
Stelle
5.4k
Fork
1k
Merge medio
22h 17m
PR unite (30g)
3

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di opencv/opencv-python

Tutte le issue di opencv/opencv-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.