我的相机校准和失真矩阵,从 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]]
图像,我尝试检测的位置:
aruco_simple.exe 成功
但是 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版本失败?谢谢!
最佳答案
您可能使用的字典与您的图片不符。根据documentation cv2.aruco.DICT_ARUCO_ORIGINAL 是 5x5:
DICT_ARUCO_ORIGINAL: standard ArUco Library Markers. 1024 markers, 5x5 bits, 0 minimum distance
您的图片有 6x6 图标而不是 5x5,这就是它不起作用的原因。
您可以使用函数 drawMarker() 在图像中绘制字典的一些标记,然后将它们打印出来并用于您的测试。
例如,here你可以download DICT_4X4_50 icons .您可以打印它们并更改您的代码以使用 DICT_4X4_50 而不是 DICT_ARUCO_ORIGINAL
关于python - cv2.aruco.detectMarkers 不检测 python 中的标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47899071/