-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathface_mask_detection_in_code_.py
61 lines (39 loc) · 1.21 KB
/
face_mask_detection_in_code_.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
"""Face Mask_detection in Code .ipynb
Automatically generated by Colaboratory.
# Importing the dependencies
import os
from tensorflow.keras.preprocessing import image
import cv2
import random
import numpy as np
import cv2
import tensorflow
import keras
from PIL import Image
face_cascade = 'haarcascade_frontalface_default.xml'
webcam = cv2.VideoCapture(0)
success, image_bgr = webcam.read()
while True:
success, image_bgr = webcam.read()
if success:
image_bw = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2GRAY)
face_classifier = cv2.CascadeClassifier(face_cascade)
faces = face_classifier.detectMultiScale(image_bw)
print(f'There are {len(faces)} faces found.')
for face in faces:
x, y, w, h = face
cv2.rectangle(image_bgr, (x, y), (x+w, y+h), (0,255,0), 2)
cv2.imshow("Face Detection", image_bgr)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
webcam.release()
cv2.destroyAllWindows()
"""Wait Wait !!
This is only 10% of project Code. [Incomplete]
If you want full Project Code with full explanation.
Please :
# Mail me at **vatshayan007@gmail.com**
"""