I’m having assertion error in opencv using python.
I will post first the code then the error from the terminal.
#Aruco properties
self.aruco_dict = aruco.Dictionary_get(aruco.DICT_5X5_50)
self.aruco_size = 0.05
self.aruco_params = aruco.DetectorParameters_create()
self.aruco_params.cornerRefinementMethod = aruco.CORNER_REFINE_SUBPIX
self.aruco_params.cornerRefinementWinSize = 5
self.aruco_params.cornerRefinementMinAccuracy = 0.001
self.aruco_params.cornerRefinementMaxIterations = 5
self.mtx = []
self.dist = []
self.load_camera_info()
self.getArucoPose()
def load_camera_info(self):
#load camera calibration
d435_camera_info = rospy.wait_for_message(self.d435_camera_info_topic, CameraInfo)
print("Camera Info Loaded")
self.mtx = d435_camera_info.K
self.dist = d435_camera_info.P
return 0
def getD435Image(self):
d435_image = rospy.wait_for_message(self.d435_image_topic, Image)
print("d435 image Loaded")
image = self.cv_bridge.imgmsg_to_cv2(d435_image, desired_encoding='bgr8')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
return image, gray
def getArucoPose(self):
color_img, input_image = self.getD435Image()
corners, ids, rejectedImgPoints = aruco.detectMarkers(color_img, self.aruco_dict, parameters=self.aruco_params)
rvecs, tvecs, trash = aruco.estimatePoseSingleMarkers(corners, self.aruco_size, self.mtx, self.dist)
print(rvecs)
The error is
Camera Info Loaded
d435 image Loaded
OpenCV Error: Assertion failed (src.size == dst.size && src.channels() == dst.channels()) in cvConvertScale, file /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/core/src/convert.cpp, line 5903
Traceback (most recent call last):
File “aruco_detect.py”, line 247, in
ur10_camera_calibration()
File “aruco_detect.py”, line 82, in init
self.getArucoPose()
File “aruco_detect.py”, line 146, in getArucoPose
rvecs, tvecs, trash = aruco.estimatePoseSingleMarkers(corners, self.aruco_size, self.mtx, self.dist)
cv2.error: /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/core/src/convert.cpp:5903: error: (-215) src.size == dst.size && src.channels() == dst.channels() in function cvConvertScale
I believe its something related to lists in python ?
I appreciate any help, thanks.