# RealTimeFaceRecognition **Repository Path**: peter_small_f/RealTimeFaceRecognition ## Basic Information - **Project Name**: RealTimeFaceRecognition - **Description**: OpenCV Haarcascade and SVM for real time facial tracking and recognition using webcam - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-12-24 - **Last Updated**: 2021-06-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RealTimeFacialRecognition Built with Python 2.7, OpenCV2, Numpy, Scipy, scikit-learn, matplotlib. * note: this application currently only works on Mac because of forward slash in path is incompatible with windows Summary -------------- Real time facial tracking and recognition using harrcascade and SVM(Radial Basis Function Kernal). Designed SVM classification model using cross-validation and exhaustively grid search, implemented using scikit in python, and trained on Extended Yale Database B. Achieved facial Tracking in OpenCV and optimized Haarcascade to detect up to 45 degrees head tilting. To build the model, 2452 samples from 38 people in the database are splitted into training and testing sets by a ratio of 3:1. The top 150 eigenfaces are extracted from 1839 training faces in the database using Principal Component Analysis (PCA). The principal components are then feeded into the C-SVM Classification model and trained with various kernel tricks. At the end of the recognition task, an accuracy of 93.3% is obtained with the Radial Basis Function (RBF) kernel on the testing set of 613 samples. The dataset used is the Extended Yale Face Database B Cropped http://vision.ucsd.edu/~leekc/ExtYaleDatabase/ExtYaleB.html Requirements -------------- - Install `OpenCV` on mac: http://www.mobileway.net/2015/02/14/install-opencv-for-python-on-mac-os-x/ - To install other dependencies, cd into ./scripts/ then run: ``pip install -r requirements.txt`` Use as local command-line utility --------------------------------- $ git clone https://github.com/AlexOuyang/RealTimeFaceRecognition.git Training For Face Recognition ------------------------------- Training for face recognition using the command below. face_profile_name is the name of the user face profile directory that you want to create in the default ../face_profiles/ folder for storing user face images and training the SVM classification model: python train.py [face_profile_name=] Example to create a face profile named David: python train.py David Usage during run time: press and hold 'p' to take pictures of you continuously once a cropped face is detected from a pop up window. All images are saved under ../face_profiles/face_profile_name press 'q' or 'ESC' to quit the application Running Face Recognition In Real Time -------------------------------------- Running the program in real time to recognize faces: python main.py Or running with options (By default, scale_multiplier = 4): python main.py [scale_multiplier=] Say you want to run with 1/2 of the full sreen size, specify that scale_multiplier = 4: python main.py 4 Top 12 Eigenfaces generated from the Extended Yale Database B -------------- ![alt text](https://raw.githubusercontent.com/AlexOuyang/RealTimeFaceRecognition/master/screenshots/face_eigen.png "Top 12 Eigenfaces generated from the Extended Yale Database B") Top 12 Predictions -------------- ![alt text](https://raw.githubusercontent.com/AlexOuyang/RealTimeFaceRecognition/master/screenshots/face_predict.png "Top 12 Predictions") Auther: Alex Chenxing Ouyang