Skip to content

Instantly share code, notes, and snippets.

import cv2
group_of_people_image = cv2.imread('images/image7.jpg')
frontal_face_classifier = cv2.CascadeClassifier('classifier/haarcascade_frontalface_default.xml')
image_in_gray_scale = cv2.cvtColor(group_of_people_image, cv2.COLOR_BGR2GRAY)
faces = frontal_face_classifier.detectMultiScale(image=image_in_gray_scale, scaleFactor=1.3, minNeighbors=6)
for (x_axis, y_axis, weight, height) in faces:
cv2.rectangle(group_of_people_image, (x_axis, y_axis), (x_axis + weight, y_axis + height), (255, 0, 0), 2)
import cv2
import dlib
import numpy as np
initial_image = cv2.imread('images/image9.jpg')
initial_image_in_rgb = cv2.cvtColor(initial_image, cv2.COLOR_BGR2RGB)
reference_image = initial_image_in_rgb.copy()
classifier_path = dlib.shape_predictor('classifier/shape_predictor_68_face_landmarks.dat')
frontal_face_detector = dlib.get_frontal_face_detector()