pip install opencv-python
- Download "haarcascade_frontalface_default.xml" from haarcascade
- 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.
- 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
- run "face-recognition" to test face recognition