swagatobag2000 / face-recognition-openCV

This module gets first trained by the pre-trained haar-cascade classifier, then using collected face data, it recognizes the user.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

face-recognition

Screenshots

How to make face-recognition module

1. Install required Python Packages:

pip install opencv-python

2. Download the pre-trained classifier

  • Download "haarcascade_frontalface_default.xml" from haarcascade

3. Start Testing Face Detection

  • use "opencv-face-testing.ipynb" to check if openCV is working or not
# Choose an image to detect faces in
frame = cv2.imread('swagato.jpeg')
# Iterate forever over frames
while True:
    # Read the current frame
#     successful_frame_read, frame = webcam.read()
    # Must convert to grayscale
    grayscaled_img = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
    ....

  • We can see the static image is detected by green rectangle
# Iterate forever over frames
while True:
    # Read the current frame
    successful_frame_read, frame = webcam.read()
    # Must convert to grayscale
    grayscaled_img = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
    ....
  • now, uncomment the line which we commented in previous step, to fetch live image with webcam

  • webcam application will pop up and one rectangle will show up when we run the notebook like above.
  • using haarcascade classifier we are detecting faces
  • if we press 'q', the webcam window will be closed.

4. Collect Data

  • run "face-data-collect.ipynb" to collect data as .npy or numpy files
  • It will first ask name of the person and the face data will be recorded as a numpy file followd by this
  • file will be saved at "data" directory

5. Perform Face Recognition

  • run "face-recognition" to test face recognition

About

This module gets first trained by the pre-trained haar-cascade classifier, then using collected face data, it recognizes the user.


Languages

Language:Jupyter Notebook 100.0%