estimatePoseSingleMarkers从 version 4.7 起不再存在,这里我用SolvePnP代替了这个函数:
def my_estimatePoseSingleMarkers(corners, marker_size, mtx, distortion):
'''
This will estimate the rvec and tvec for each of the marker corners detected by:
corners, ids, rejectedImgPoints = detector.detectMarkers(image)
corners - is an array of detected corners for each detected marker in the image
marker_size - is the size of the detected markers
mtx - is the camera matrix
distortion - is the camera distortion matrix
RETURN list of rvecs, tvecs, and trash (so that it corresponds to the old estimatePoseSingleMarkers())
'''
marker_points = np.array([[-marker_size / 2, marker_size / 2, 0],
[marker_size / 2, marker_size / 2, 0],
[marker_size / 2, -marker_size / 2, 0],
[-marker_size / 2, -marker_size / 2, 0]], dtype=np.float32)
trash = []
rvecs = []
tvecs = []
i = 0
for c in corners:
nada, R, t = cv2.solvePnP(marker_points, corners[i], mtx, distortion, False, cv2.SOLVEPNP_IPPE_SQUARE)
rvecs.append(R)
tvecs.append(t)
trash.append(nada)
return rvecs, tvecs, trash
1条答案
按热度按时间ewm0tg9j1#
estimatePoseSingleMarkers从 version 4.7 起不再存在,这里我用SolvePnP代替了这个函数: