0

I am in trouble figuring out why cv2.aruco.detectMarkers() has problems in finding more than just a few markers with my calibration board. Playing around with the paramters didn't essentially improve the quality. The dictionary is correct as I tried it with the digital template before printing. Here is, what I do to detect CHAruco markers from a real image:

import cv2
from cv2 import aruco
#ChAruco board variables
CHARUCOBOARD_ROWCOUNT = 26
CHARUCOBOARD_COLCOUNT = 26
ARUCO_DICT = cv2.aruco.Dictionary_get(aruco.DICT_4X4_1000)

#Create constants to be passed into OpenCV and Aruco methods
CHARUCO_BOARD = aruco.CharucoBoard_create(
    squaresX=CHARUCOBOARD_COLCOUNT,
    squaresY=CHARUCOBOARD_ROWCOUNT,
    squareLength=5, #mm
    markerLength=4, #mm
    dictionary=ARUCO_DICT)

 #load image     
 img = cv2.imread('imgs\\frame25_crop.png', 1)

test image with CHAruco markers

#initialize detector
parameters =  aruco.DetectorParameters_create()
parameters.adaptiveThreshWinSizeMin = 150
parameters.adaptiveThreshWinSizeMax = 186

#Find aruco markers in the query image
corners, ids, _ = aruco.detectMarkers(
    image=img,
    dictionary=ARUCO_DICT,
    parameters=parameters)   

#Outline the ChAruco markers found in our image
img = aruco.drawDetectedMarkers(
    image=img, 
    corners=corners)

The result is the following: only 3 are markers are found, which is bad.

resulting image with found markers

Does anyone has an idea how to considerably improve the results of the detector?

mt-cv
  • 23
  • 6

2 Answers2

0

Without looking at your code I may say that the image quality and perspective you selected is a bit poor. You may try to work with more clear view of your markers. For instance, hang the markers on the wall take one or two step back and try to take photo of it with better light and if not necessary do not add extra rotation, and keep the contrast high :). This will probably give better results.

Dharman
  • 30,962
  • 25
  • 85
  • 135
lexi
  • 46
  • 5
0

Your image is flipped.

Fix it with this line of code:

img = cv2.flip(img, 0)
ZygD
  • 22,092
  • 39
  • 79
  • 102