cv2.aruco.detectMarkers doesn't detect markers in python

My camera calibration and distortion matrixes, obtained from aruco_calibration_fromimages.exe :

 [[3.19439125e+03   0.00000000e+00   1.98509417e+03]  
  [0.00000000e+00   3.20213561e+03   1.55099552e+03]  
  [0.00000000e+00   0.00000000e+00   1.00000000e+00]]

 [[0.1395281  -0.38313647  0.00505558  0.00237535  0.33952515]]

Image, where I try to detect:

在这里输入图像描述

aruco_simple.exe succeeds

在这里输入图像描述

But python code fails to find anything:

fs = cv2.FileStorage("./calib_asus_chess/cam_calib_asus.yml", cv2.FILE_STORAGE_READ)
cam_mat=fs.getNode("camera_matrix").mat()
dist_mat=fs.getNode("distortion_coefficients").mat()
gray=cv2.imread('C:UserssteveDropboxProjectskinnektlaseraruco_framesshot1.jpg',0)
adict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_ARUCO_ORIGINAL)
res = cv2.aruco.detectMarkers(gray,dictionary=adict,cameraMatrix=cam_mat,distCoeff=dist_mat)

res[0] is empty array for some reason. Why python version fails? Thanx!


You are probably using a dictionary that does not correspond to your image. According to the documentation cv2.aruco.DICT_ARUCO_ORIGINAL is 5x5:

DICT_ARUCO_ORIGINAL: standard ArUco Library Markers. 1024 markers, 5x5 bits, 0 minimum distance

Your image has 6x6 icons instead of 5x5, this is why it doesn't work.

You could use the function drawMarker() to draw some markers of the dictionary in an image and then print them and use them for your test.

For example, here you can download DICT_4X4_50 icons. You can print them and change your code to use DICT_4X4_50 instead of DICT_ARUCO_ORIGINAL

链接地址: http://www.djcxy.com/p/40974.html

上一篇: Firebase功能从Firebase DB获取数据以进行推送通知

下一篇: cv2.aruco.detectMarkers在python中不检测标记