gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) faces = faceCascade.detectMultiScale( gray, scaleFactor=1.1, minNeighbors=10, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE ) height, width, channels = frame.shape cv2.line(frame, (width / 2, 0), (width / 2, height), color=(0, 0, 255)) if len(faces) == 0: arduino.push("0 0") # Draw a rectangle around the faces for (x, y, w, h) in faces: cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2) centerX = x + (w / 2) centerY = y + (h / 2) center = (centerX, centerY) cv2.circle(frame, center, 20, color=(0, 0, 255)) if x < width /2 and x + w > width / 2: push_x = 0 elif width / 2 > centerX: push_x = -1 else:
class Eye: def __int__(self): self.arduino = Arduino() def look(self, x, y): self.arduino.push(x + " " + y + " +")