You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to adjust the face identification to focus only on eyes or really only inside the face?
The current box is too large and breaks anything outside the face (hair accessory, earrings).
Using a simpler but probably not generally accurate code we can find the eyes only.
But it has been hard to then run the fixing function through it.
Any way to make the face identification much tighter or focus only on eyes?
Thanks!
Simple code to identify only eyes.
import facexlib
import tensorflow as tf
import cv2
from google.colab.patches import cv2_imshow
# Load the Haar cascade for detecting eyes
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
# Read the image and convert it to grayscale
image = cv2.imread('img.png')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Adjust the scale factor and minimum neighbor count for the classifier
scale_factor = 1.33
min_neighbors = 18
# Detect eyes in the image
eyes = eye_cascade.detectMultiScale(gray, scale_factor, min_neighbors)
# Draw a rectangle around the eyes
for (x,y,w,h) in eyes:
cv2.rectangle(image, (x,y), (x+w, y+h), (255,0,0), 2)
# Show the image
cv2_imshow(image)
cv2.waitKey(0)
cv2.destroyAllWindows()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Is there a way to adjust the face identification to focus only on eyes or really only inside the face?
The current box is too large and breaks anything outside the face (hair accessory, earrings).
Using a simpler but probably not generally accurate code we can find the eyes only.
But it has been hard to then run the fixing function through it.
Any way to make the face identification much tighter or focus only on eyes?
Thanks!
Simple code to identify only eyes.
Beta Was this translation helpful? Give feedback.
All reactions