Skip to content

Simple face detection program using the face recognition library (based on dlib)

License

Notifications You must be signed in to change notification settings

alberterc/smart-cctv-univ-proj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart CCTV

CCTV with face detection program using simple webcam (can also be used for raspberry pi cameras although needs some adjustments).

Made with OpenCV, dlib, and pickle encryption.

Dependencies

Made with Python 3.9.7 using Visual Studio Code (Windows 10) in a virtual environment. Little bit of GUI is made with Tkinter.

?=Generated by pipreqs=?
face_recognition==1.3.0
imutils==0.5.4
opencv_python==4.5.5.62

Everything was installed using pip.

Note:

How to run?

NOTE: If you're downloading all of the files and folders, please delete the "dataset" folder before running the program for a cleaner directory.

  1. (optional) Setup a virtual environment.
python -m venv venv
  1. Activate the virtual environment.
.\venv\Scripts\Activate.ps1
  1. Install imutils with pip.
pip install imutils
  1. Install opencv with pip.
pip install opencv-python
  1. Install dlib from wheel according to python version.
pip install dlib-19.22.99-cp39-cp39-win_amd64.whl
  1. Install face recognition module with pip.
pip install face_recognition
  1. Download "main_gui" and "scripts" folder and put them in the root directory.
Directory tree example:
folder/
...main_gui/ 
...scripts/
...venv/
  1. Run main_gui/main_menu.py from the root directory.
python main_gui/main_menu.py

What are those files?

scripts/email_notify.py

Uses smtplib, mime, and datetime modules.

  • Function for adding email into the emails list file with the name 'emails.txt' in scripts/files folder.
  • Function for deleteing email from the emails list file.
  • Function for sending an email to every email in the emails list file.

scripts/encode_faces.py

Uses imutils, OpenCV, os, argparse, face recognition, and pickle modules.

  • Determine detection method (HOG or CNN, default: CNN) for the pickle file which stores face embeddings.
  • Determine what is the name for the pickle file (currently set to model.pickle) and will be stored in the same directory of encode_faces.py.

CNN: more accurate, requires more processing power and memory resources.

HOG: less accurate, requires less processing power and memory resources (use this on raspberry pi).

scripts/face_recog_main.py

Uses imutils, OpenCV, time, argparse, face recognition, and pickle modules.

  • Determine which cascade file to be used (uses the available cascade files from OpenCV).
  • Determine which pickle file to be used.
  • Shows a video output in a new window which has realtime face detection.
  • Stores the detected faces' name in a file named 'detected_names.txt' in scripts/files folder.

If an unknown face is detected, an "Unknown!" text will appear.

If a known face is detected, the name of that face will appear.

scripts/get_face_data.py

Uses Tkinter, OpenCV, time, and os modules.

  • Waits for user input for the name of the face.
  • Makes a new folder to store data (photo of a face) inside folder "dataset".
  • Captures/snapshots a frame from a video input to take a photo.
  • The amount of photos to be captured can be changed (the time it takes to finish will also change accordingly).
  • Photos are stored in 224x224 resolution with BGR color format.

scripts/get_face_data.py

Uses Tkinter, OpenCV, time, and os modules. Whole GUI code made by myself.

(still uses a bit of cli input)

  • Waits for user input for the name of the face.
  • Makes a new folder to store data (photo of a face) inside folder "dataset".
  • Captures/snapshots a frame from a video input to take a photo.
  • The amount of photos to be captured can be changed (the time it takes to finish will also change accordingly).
  • Photos are stored in 224x224 resolution with BGR color format.

scripts/live_feed_camera.py

Uses OpenCV module.

  • Checks if a camera source is present.
  • Displays video output from a camera device.

scripts/new_mail.py and scripts/new_mail_support.py

Uses Tkinter module for GUI building. Base GUI code generated using PAGE.

  • Waits for user input for user email.
  • Can either save or remove email from emails list file 'emails.txt' in the scripts/files folder.

main_gui/main_menu.py

Uses Tkinter module for GUI building. Base GUI code generated using PAGE.

  • Main menu for the program.

Notes

  • HOG detection method is required if program is running on raspberry pi.
  • Low fps when program detects any face on the video input (face_recog_main.py), might require some adjustments.

Developer

Albert E (albertenrico.5@gmail.com)

About

Simple face detection program using the face recognition library (based on dlib)

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages