def _get_tip_position(array, contour, verbose = False):
approx_contour = cv2.approxPolyDP(contour, 0.08 * cv2.arcLength(contour, True), True)
convex_points = cv2.convexHull(approx_contour, returnPoints = True)
cx, cy = 999, 999
for point in convex_points:
cur_cx, cur_cy = point[0][0], point[0][1]
if verbose:
cv2.circle(array, (cur_cx, cur_cy), 4, _COLOR_GREEN,4)
if (cur_cy < cy):
cx, cy = cur_cx, cur_cy
(screen_x, screen_y) = pyautogui.size()
height, width, _ = array.shape
x = _round_int((float(cx))/(width-0)*(screen_x+1))
y = _round_int((float(cy))/(height-0)*(screen_y+1))
return (array, (x, y))
评论列表
文章目录