简体   繁体   English

由于 objPoints 类型,将 board_create 用于 aruco 标记时出错

[英]Error using board_create for aruco markers due to objPoints type

I want to be able to detect aruco markers on a 3D object and I'm therefore trying to create my own custom aruco board in OpenCV, with the locations of the markers.我希望能够在 3D object 上检测到 aruco 标记,因此我尝试在 OpenCV 中创建我自己的自定义 aruco 板,以及标记的位置。

I have produced a snippet of the code, to reproduce the error.我制作了一段代码来重现错误。

# Load the ArUco dictionary
arucoDict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_4X4_50)
arucoParams = cv2.aruco.DetectorParameters_create() 

#Create new custom aruco board
board_corners = [np.array([[0.007,0.096,0.0],[0.099,0.096,0.0],[0.099,0.005,0.0],[0.007,0.005,0.0]],dtype=np.float32),
np.array([[0.0,0.099,0.006],[0.0,0.005,0.006],[0.0,0.005,0.096],[0.0,0.099,0.096]],dtype=np.float32),
np.array([[0.007,0.0,0.006],[0.099,0.0,0.006],[0.099,0.0,0.097],[0.007,0.0,0.097]],dtype=np.float32),
np.array([[0.007,0.096,0.103],[0.007,0.005,0.103],[0.099,0.005,0.103],[0.099,0.096,0.103]],dtype=np.float32)]

#Id's for aruco marker on board
board_ids = np.array([[0],[1],[2],[3]], dtype=np.int32)

#Creating board
board = cv2.aruco.Board_create(board_corners,arucoDict, board_ids )

which produce the following error产生以下错误

cv2.error: /build/opencv-L2vuMj/opencv-3.2.0+dfsg/contrib/modules/aruco/src/aruco.cpp:1281: error: (-215) objPoints.type() == CV_32FC3 in function create

From what I understand the error happens when the datatype is not in float32, as the function requires.据我了解,当数据类型不在 float32 中时会发生错误,如 function 所要求的那样。 But I already changed the datatype to np.float32 and I'm not sure why I still get the error.但是我已经将数据类型更改为 np.float32 并且我不确定为什么我仍然会收到错误消息。

Hope someone knows what I have missed.希望有人知道我错过了什么。

I managed to solve the problem myself.我设法自己解决了这个问题。 The problem was I was running a too old version of OpenCV. The version needs to be 3.4.x or above since it was a bug that got fixed in 3.4.问题是我运行的 OpenCV 版本太旧。版本需要是 3.4.x 或更高版本,因为它是一个在 3.4 中修复的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM