OpenCV-Python Cheat Sheet: From Importing Images to Face Detection
Face Detection
Can’t have dog pictures here, sadly
Photo by Free-Photos from Pixabayimport cv2image_path = = = cv2.imread(image_path)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faces = gray,
scaleFactor= 1.1,
minNeighbors= 5,
minSize=(10, 10)
)faces_detected = format(len(faces)) + ” faces Draw a rectangle around the faces
for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x+w, y+h), (255, 255, 0), detectMultiScale function is a general function that detects objects. The detection algorithm uses a moving window to detect objects. minNeighbors defines how many objects are detected near the current one before it declares the face found.
Source: heartbeat.fritz.ai