Skip to content

Commit

Permalink
#4 Implemented Detector class
Browse files Browse the repository at this point in the history
  • Loading branch information
mbenkus committed Dec 29, 2019
1 parent 7ec7095 commit d6d3dc4
Show file tree
Hide file tree
Showing 2 changed files with 134,484 additions and 0 deletions.
25 changes: 25 additions & 0 deletions modules/Detector.py
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)
Loading

0 comments on commit d6d3dc4

Please sign in to comment.