-
Notifications
You must be signed in to change notification settings - Fork 925
Description
Problem description
I am porting code from 4.6.0.66 to 4.7. Aruco has moved from contrib to the main package, and some functions have been renamed.
I cannot figure out how to call the cv2.aruco.Board
constructor. Even though i put in a list of points and a list of ids of the same size, it always gives me an error that they are not the same length.
Steps to reproduce
Python 3.10, Windows 11, x64
Using opencv-contrib-python 4.6.0.66 this worked:
# boardCornerPoints is a list of 4x2 float32 matrices, e.g.:
# boardCornerPoints[0] ->
# array([[-178.05125, -151.86725],
# [-136.15675, -151.86725],
# [-136.15675, -109.97275],
# [-178.05125, -109.97275]], dtype=float32)
boardCornerPoints = np.dstack(boardCornerPoints) # list of 2D arrays -> 3D array
boardCornerPoints = np.rollaxis(boardCornerPoints,-1) # 4x2xN -> Nx4x2
boardCornerPoints = np.pad(boardCornerPoints,((0,0),(0,0),(0,1)),'constant', constant_values=(0.,0.)) # Nx4x2 -> Nx4x3
cv2.aruco.Board_create(boardCornerPoints, self.aruco_dict, np.array(ids))
Now with 4.7.0.68, this (calling cv2.aruco.Board(boardCornerPoints, self.aruco_dict, np.array(ids))
) no longer works despite that the signature of the C++ function has not changed (compare https://github.com/opencv/opencv/blob/4.7.0/modules/objdetect/src/aruco/aruco_board.cpp#L158 and https://github.com/opencv/opencv_contrib/blob/4.6.0/modules/aruco/src/aruco.cpp#L1613).
The error i get is:
cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\objdetect\src\aruco\aruco_board.cpp:160: error: (-215:Assertion failed) ids.size() == objPoints.size() in function 'cv::aruco::Board::Board'
Since the signature has not changed, i assume this is some error in the python wrapper?
Issue submission checklist
- This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
- I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
- The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
- I'm using the latest version of
opencv-python