python - cv2.aruco.detectMarkers 不检测 python 中的标记

标签 python opencv aruco

我的相机校准和失真矩阵,从 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版本失败?谢谢!

最佳答案

您可能使用的字典与您的图片不符。根据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/

相关文章:

python - 屏蔽 numpy 数组中的圆形扇区

python - 在Python中构建3维数据表面数据的三角网格

python - 使用 Pandas 的字典键和值的列名称

android - 等高线图 OpenCV4Android 库

image - 在图像中用白色替换黑色,用白色替换黑色

python - OpenCV-ArUco中tvecs rvecs的基本理解

python - 类的任何子类的实例的类型提示

c++ - 在 OpenCV 中计算两个 Mat 文件的相关性

opencv - 使用自定义相机(AruCo)的Unity3D和OpenCV

opencv - Aruco 期望什么图像编码?