Realtime Face/Edge Detection

Realtime Face/Edge Detection

View on Github ~~>
computer vision
machine learning

Realtime Face/Edge Detection


Built a real-time face detection/recognition command line program using OpenCV. Also implemented a near real-time canny edge detector using the same system.

Technologies Used

  • Python
  • OpenCV
  • Numpy
  • Pandas

Face Detection

Face detection is done using the Haar Cascade Classifier. The classifier is trained on a dataset of faces and is able to detect faces in real time. The classifier is implemented in the file.

Face Recognition

Face recognition is achieved using a Local Binary Patterns Histograms (LBPH) classifier using images captured from the system and cropped using the face detector. The classifier is implemented in the file.

Edge Detection

Edge detection is done using the Canny Edge Detector. The detector is implemented in the file.

How to Use

To use the program, first open and adjust settings as desired. From there, run and read given options from the system:


  1. Detect Faces (No recognition)
  2. Add User to Recognizer
  3. Retrain Faces
  4. Recognize Faces
  5. Detect Edges
  6. Quit

Select option 1 to just detect faces without reconition Select option 2 to add a user’s face to the reconizer Select option 3 to retrain all faces in db.csv Select Option 4 to perform recognition Select option 5 for edge detection Select option 6 to quit


  • Press q during any video capture to end the capture and return to the options menu
  • A user may already be in the database file with the same face. If so, remove them from db.csv and delete their dataset folder. Then run option 2
  • If there are no users in db.csv, or the trainer.yml file is missing, this will not work

Future Work

  • Add a GUI
  • Add a database to store user information
  • Add a way to remove users from the database
  • Add a way to update user information
  • Add a way to update user images


© 2024 Joshua Gracie
Thanks for stopping by! Don't forget to check out my LinkedIn 💼 and TryHackMe