├── LICENSE ├── README.md ├── app.py ├── default.xml └── requirements.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Abhineet Raj 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FaceDectection (in python) 2 | This project helps to locate/visualize human faces through digital camera. 3 | 4 | ## Installation 5 | * Download python 3.8 6 | * Use pip command to install the libraries 7 | ``` 8 | pip3 install -r requirements.txt 9 | ``` 10 | * If your facing problem while installing PyAudio in python, then download PyAudio from [here](https://www.lfd.uci.edu/%7Egohlke/pythonlibs/), according to your system configuration and run:- 11 | ``` 12 | pip3 install filename 13 | ``` 14 | * run app.py 15 | ``` 16 | python3 app.py 17 | ``` 18 | ## Note:- 19 | * Do not delete default.xml file 20 | * The face detection models are trained according to 2022 data. 21 | ## Programming languages used 22 | Python 23 | 24 | ## Authors 25 | [@abhineetraj1](https://github.com/abhineetraj1) 26 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import pyttsx3 3 | f=[0] 4 | igm = cv2.VideoCapture(0) 5 | faceCascade = cv2.CascadeClassifier("default.xml") 6 | 7 | 8 | def vr(n): 9 | if (f[0] == n): 10 | n=2 11 | else: 12 | f.remove(f[0]) 13 | f.append(n) 14 | if (n>1): 15 | pyttsx3.speak(f"{str(n)} faces found") 16 | else: 17 | pyttsx3.speak(f"{str(n)} face found") 18 | 19 | while(True): 20 | ret, frame = igm.read() 21 | gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 22 | faces = faceCascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30) ) 23 | vr(len(faces)) 24 | for (x, y, w, h) in faces: 25 | cv2.putText(frame, "Human", (x, y - 10), cv2.FONT_HERSHEY_DUPLEX, 1, (0,0,0), 2) 26 | cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2) 27 | cv2.imshow('frame', frame) 28 | if cv2.waitKey(1) & 0xFF == ord('q'): 29 | break 30 | igm.release() 31 | cv2.destroyAllWindows() 32 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyttsx3 2 | opencv-python --------------------------------------------------------------------------------