cv2.aruco.detectMarkers在python中没有检测到标记

问题描述 投票:8回答:1

我的相机校准和失真矩阵,从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]]

图片,我试图检测:

enter image description here

aruco_simple.exe成功

enter image description here

但是python代码找不到任何东西:

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:\\Users\\steve\\Dropbox\\Projects\\kinnekt\\laser\\aruco_frames\\shot1.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]是空数组。为什么python版本失败了?感谢名单!

python opencv aruco
1个回答
5
投票

您可能正在使用与您的图像不对应的字典。根据documentation cv2.aruco.DICT_ARUCO_ORIGINAL是5x5:

DICT_ARUCO_ORIGINAL:标准的ArUco图书馆标记。 1024个标记,5x5位,0最小距离

您的图像有6x6图标而不是5x5,这就是为什么它不起作用。

您可以使用函数drawMarker()在图像中绘制字典的一些标记,然后打印它们并将它们用于测试。

例如,here你可以download DICT_4X4_50 icons。您可以打印它们并更改代码以使用DICT_4X4_50而不是DICT_ARUCO_ORIGINAL

© www.soinside.com 2019 - 2024. All rights reserved.