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

烂漫一生 提交于 2019-12-10 03:16:31

问题


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:\\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] is empty array for some reason. Why python version fails? Thanx!


回答1:


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



来源:https://stackoverflow.com/questions/47899071/cv2-aruco-detectmarkers-doesnt-detect-markers-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!