Search code examples
pythonopencvaugmented-realityaruco

ArUco marker Detection ids None


Hey everyone i recently started to learn arUco markers for detecting a specific point in image so i generate a simple marker with id 10 but when i tried to detect it with my python code

import math
import cv2
import cv2.aruco as aruco

img = cv2.imread("temp.jpg")

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

aruco_dict = aruco.Dictionary_get(aruco.DICT_5X5_250)

parameters = aruco.DetectorParameters_create()

# print(parameters)

corners, ids, _ = aruco.detectMarkers(gray, aruco_dict, parameters=parameters)
# cv2.imshow("img", img)
# ids = 10
print(ids)

cv2.waitKey(0)

i didn't get the ids instead of number it shows none and also value of corner is empty list after that i copy a code from the internet to check weather the detection is working or not but still that code gives me the same output here i have shared two output images first one is from my above code and second one is from the code that i copied from internet

enter image description here

enter image description here


Solution

  • You are using the ArUco markers generator site that by default generate a 4x4 aruco marker size.

    Using your image enter image description here

    I got [[0]] by changing

    aruco_dict = aruco.Dictionary_get(aruco.DICT_5X5_250)

    to

    aruco_dict = aruco.Dictionary_get(aruco.DICT_4X4_250)