I know my brain is rotting, but I just can’t stop.
import cv2
# Load the Haar cascade file for eye detection
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
# Initialize the video capture
cap = cv2.VideoCapture(0)
while True:
# Read the video frame
ret, frame = cap.read()
# Convert the frame to grayscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Detect eyes in the grayscale frame
eyes = eye_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30))
# Iterate through the detected eyes
for (x, y, w, h) in eyes:
# Draw rectangles around the eyes
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
# Display the resulting frame
cv2.imshow('Eye Tracking', frame)
# Exit the loop when 'q' is pressed
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release the video capture and close the windows
cap.release()
cv2.destroyAllWindows()
import cv2
# Load the Haar cascade file for eye detection
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
# Initialize the video capture
cap = cv2.VideoCapture(0)
while True:
# Read the video frame
ret, frame = cap.read()
# Convert the frame to grayscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Detect eyes in the grayscale frame
eyes = eye_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30))
# Iterate through the detected eyes
for (x, y, w, h) in eyes:
# Draw rectangles around the eyes
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
# Display the resulting frame
cv2.imshow('Eye Tracking', frame)
# Exit the loop when 'q' is pressed
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release the video capture and close the windows
cap.release()
cv2.destroyAllWindows()
Category All / Abstract
Species Unspecified / Any
Size 2113 x 1585px
File Size 2.04 MB
FA+

Comments