import pyautogui
import cv2
# Load the pre-trained cascade classifier for detecting objects
cascade_classifier = cv2.CascadeClassifier('path/to/haarcascade_frontalface_default.xml')
# Capture the screen
screen = pyautogui.screenshot()
# Convert the screenshot (PIL Image) to a numpy array
frame = cv2.cvtColor(np.array(screen), cv2.COLOR_RGB2BGR)
# Detect object(s) in the frame
objects = cascade_classifier.detectMultiScale(frame, scaleFactor=1.1, minNeighbors=5, minSize=(100, 100))
# Move the mouse to the center of the first detected object (if any)
if len(objects) > 0:
object_x = objects[0][0] + objects[0][2] / 2
object_y = objects[0][1] + objects[0][3] / 2
mouse_x, mouse_y = pyautogui.position()
pyautogui.moveTo(mouse_x + object_x, mouse_y + object_y, duration=0.25)