def calculateCorners(self, gray, points=None):
'''
gray is OpenCV gray image,
points is Marker.points
>>> marker.calculateCorners(gray)
>>> print(marker.corners)
'''
if points is None: points = self.points
if points is None: raise TypeError('calculateCorners need a points value')
'''
rotations = 0 -> 0,1,2,3
rotations = 1 -> 3,0,1,2
rotations = 2 -> 2,3,0,1
rotations = 3 -> 1,2,3,0
=> A: 1,0,3,2; B: 0,3,2,1; C: 2,1,0,3; D: 3,2,1,0
'''
i = self.rotations
A = (1,0,3,2)[i]; B = (0,3,2,1)[i]; C = (2,1,0,3)[i]; D = (3,2,1,0)[i]
corners = np.float32([points[A], points[B], points[C], points[D]])
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.1)
self.corners = cv2.cornerSubPix(gray, corners, (5,5), (-1,-1), criteria)
评论列表
文章目录