cv2.aruco.detectMarkers无法检测python中的标记 [英] cv2.aruco.detectMarkers doesn't detect markers in python

查看:1112
本文介绍了cv2.aruco.detectMarkers无法检测python中的标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

aruco_calibration_fromimages.exe 获得的我的相机校准和失真矩阵:

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 成功

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

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:\\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版本失败?谢谢!

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

推荐答案

您使用的词典可能与您的图片不符.根据文档 cv2.aruco.DICT_ARUCO_ORIGINAL为5x5:

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:标准ArUco库标记. 1024个标记,5x5位,最小距离0

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

您的图片具有6x6的图标,而不是5x5,这就是为什么它不起作用的原因.

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

您可以使用函数drawMarker()在图像中绘制词典的一些标记,然后将其打印出来并用于测试.

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

这篇关于cv2.aruco.detectMarkers无法检测python中的标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆