-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
label_recognizer.py
35 lines (28 loc) · 1.37 KB
/
label_recognizer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import numpy as np
import cv2
from utils import CFEVideoConf, image_resize
cap = cv2.VideoCapture(0)
save_path = 'saved-media/glasses_and_stash.mp4'
frames_per_seconds = 24
config = CFEVideoConf(cap, filepath=save_path, res='720p')
out = cv2.VideoWriter(save_path, config.video_type, frames_per_seconds, config.dims)
face_cascade = cv2.CascadeClassifier('cascades/data/haarcascade_frontalface_default.xml')
eyes_cascade = cv2.CascadeClassifier('cascades/third-party/frontalEyes35x16.xml')
nose_cascade = cv2.CascadeClassifier('cascades/third-party/Nose18x15.xml')
glasses = cv2.imread("images/fun/glasses.png", -1)
mustache = cv2.imread('images/fun/mustache.png',-1)
'''
OpenCV & Python Tutorial Video Series: https://kirr.co/ijcr59
Eyes Cascade (and others): https://kirr.co/694cu1
Nose Cascade / Mustache Post: https://kirr.co/69c1le
'''
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA)
for (x, y, w, h) in faces:
roi_gray = gray[y:y+h, x:x+h] # rec
roi_color = frame[y:y+h, x:x+h]
#cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 255, 255), 3)