-
Notifications
You must be signed in to change notification settings - Fork 0
CV algorithms
We used material from this article to create new face mask recognition. We want to remove eyes and hairs from skin tone recognition.
For face mask recognition were used mediapipe library.
For face mask configuration as shape used ideas from this answer.
Use Haar cascades for face detection (opencv/build/etc/haarcascades)
face_cascade_db = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
Detect face
face = face_cascade_db.detectMultiScale(img, 1.1, 19)
Square face (Only for the demo)
for (x,y,w,h) in face:
cv2.rectangle(img, (x,y), (x+w,y+h), (0,255,0), 2)
Use KMeans from sklearn to make color-clusters
k_means = KMeans(n_clusters=1)
Create k_means
k_means.fit(image.reshape(image.shape[0] * image.shape[1], 3))
Fit to k_means image (with flatten shape in 0 and 1 axis)
tuple(map(int, self.k_means.cluster_centers_[0]))
Get color in BGR format