-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mbenkus
committed
Dec 29, 2019
1 parent
7ec7095
commit d6d3dc4
Showing
2 changed files
with
134,484 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import cv2 | ||
|
||
class Detector(): | ||
|
||
def _find_faces(self, image: object) -> int: | ||
""" | ||
Uses OpenCV to recognize faces in the taken picture. | ||
Arguments: | ||
object: Previously taken image (or any image). | ||
Returns: | ||
int: Number of recognized faces in the picture. | ||
casc_path = 'haarcascade_frontalface_default.xml' | ||
face_cascade = cv2.CascadeClassifier(casc_path) | ||
""" | ||
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml') | ||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | ||
faces = face_cascade.detectMultiScale( | ||
gray, | ||
scaleFactor=1.1, | ||
minNeighbors=5, | ||
minSize=(30, 30), | ||
flags=cv2.CASCADE_SCALE_IMAGE | ||
) | ||
return len(faces) |
Oops, something went wrong.