# Example action: click on a specific color for contour in contours: area = cv2.contourArea(contour) x, y, w, h = cv2.boundingRect(contour) aspect_ratio = float(w)/h # If the contour matches your target (color, size, aspect ratio), perform an action if 100 < area < 1000 and 2 < aspect_ratio < 4: pyautogui.click(x+w/2, y+h/2) break
What you will find is: