2

I'm trying to detect the ArUco markers in this image:

img

using this code:

import cv2
import cv2.aruco as aruco
import numpy as np

def findArucoMarkers(img, markerSize = 5, totalMarkers=250, draw=True):    
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    key = getattr(aruco, f'DICT_{markerSize}X{markerSize}_{totalMarkers}')
    arucoDict = aruco.Dictionary_get(key)
    arucoParam = aruco.DetectorParameters_create()
    bboxs, ids, rejected = aruco.detectMarkers(gray, arucoDict, parameters = arucoParam)
    print(ids)
    if draw:
        aruco.drawDetectedMarkers(img, bboxs)
    return [bboxs, ids]

path = ""
imName= "test3.png"

img = cv2.imread(path+imName)

arucofound = findArucoMarkers(img, markerSize = 5)

cv2.imshow('img',img)
cv2.waitKey(0)

Sadly, no marker is detected! can you please tell me how can I detect the markers correctly? thanks in advance.

Edit:

The markers are 5x5 generated online from this website, the IDs: 0, 2, 4, 12, 17

The camera used Asus Xtion Live Pro.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Bilal
  • 3,191
  • 4
  • 21
  • 49
  • are you *sure* it's the 5X5 type, not some other type with 5x5 modules? there's some "classic" type. – Christoph Rackwitz Feb 15 '22 at 13:20
  • @CristophRackwitz I'm pretty sure and tested the `findArucoMarkers` on the same marker on the video stream from my PC camera, it was working well! – Bilal Feb 15 '22 at 15:12
  • why are the required quiet zones around those markers missing? _do not_ crop the white area around the markers. it's PART of the marker. – Christoph Rackwitz Feb 15 '22 at 23:33
  • the rectangles [are detected](https://i.imgur.com/A12MxEZ.png), but they are rejected. please give exact details on what these markers are. IDs, types, etc. everything, to reproduce these markers. – Christoph Rackwitz Feb 15 '22 at 23:45
  • 1
    ... did you MIRROR THE IMAGE? that marker in the middle has ID 17... I just flipped through the first 18 aruco markers and used my eyes to compare. why are the markers mirrored? – Christoph Rackwitz Feb 15 '22 at 23:50
  • @CristophRackwitz "*did you MIRROR THE IMAGE?*" [The mirroring is happened by default in the video stream from Xtion Pro](https://answers.ros.org/question/200132/xtionopenni2-image-flipped/?answer=210208#post-id-210208) unless it is disabled!, thanks for your remark, I have edited the question with ArUco IDs. – Bilal Feb 16 '22 at 00:57

1 Answers1

4

The picture is a mirror image of the markers.

ArUco markers will not be decoded when they're mirrored.

Prevent/undo the mirroring. Find the device/driver setting that does this.

flipped = cv.flip(img, 1) flips the image around the Y-axis.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
  • 1
    thanks for your answer, the other way around is to disable the mirroring from the `OpenNi2` API using `color_stream.set_mirroring_enabled(False)`, the same goes for the `depth_stream`. – Bilal Feb 16 '22 at 08:59