Your face is the new password. Built with Python.
Introduction • Getting Started • Code • Pipeline • Version History • Contribution • Credits • License
The project involves the use of Intel's OpenCV library in conjunction with Python for realtime Face Detection and Recognition. The sole purpose of this project is to eliminate the process of typing passwords for logging into Remote Desktop and running applications within it using Python's massive package repo.
The code is primarily built in python with support for both Mac OS and Windows, however the code will work efficiently on Windows due to the packages which natively supports Windows scaling.
- Cloning Repository
- Installing Python
- Dependencies
- Choosing IDE
-
- If you've Python and OpenCV dependencies already installed in your system you can skip the below steps and clone the repository in your system by pasting
git clone https://github.com/xames3/FaceID.git
in CMD or Terminal. I'm using GitBash here.
- If you've Python and OpenCV dependencies already installed in your system you can skip the below steps and clone the repository in your system by pasting
-
- Although Python 2.7 is supported as well, it is strongly recommended to clone the project against the latest Python 3.x or minimum 3.5.x builds whenever possible. This will ensure that some of the newer features of the used packages, such as speedup mechanisms of OpenCV and Pyautogui's
pyautogui.locateOnScreen
work out of the box without any issues. You can find all Python 2 and 3 builds here. - Once you've installed Python in your system make sure you update pip using
python -m pip install --upgrade pip
command in CMD or Terminal.
- Although Python 2.7 is supported as well, it is strongly recommended to clone the project against the latest Python 3.x or minimum 3.5.x builds whenever possible. This will ensure that some of the newer features of the used packages, such as speedup mechanisms of OpenCV and Pyautogui's
-
-
After pip is updated, update all the standard built-in packages using the
pip install --upgrade <packagename>
command or use my pip updater code for updating it automatically. Please be patient as it may take sometime depending upon speed of your internet. -
For FaceID to be working we need the below mentioned Python packages to be installed:
- OpenCV:
pip install --upgrade opencv-contrib-python
- Cmake:
pip install --upgrade cmake
- Boost:
pip install --upgrade boost
- Dlib:
pip install --upgrade dlib
- Pillow:
pip install --upgrade pillow
- Pyautogui:
pip install --upgrade pyautogui
- Openpyxl:
pip install --upgrade openpyxl
- xlrd:
pip install --upgrade xlrd
- Colorama:
pip install --upgrade colorama
- OpenCV:
-
We need Haar Classifiers and Dlib's Facial Landmarks to be downloaded both of which are present in project files under Cascades.
-
-
- You can use any Python supporting IDE of your preference. I prefer working on Sublime Text 3 due to it's Package Control system and useful plugins for Python.
-
The logic built around the program is to first detect face(s) in the visible feed. If the face(s) are detected the program will try to recognize the face\person using the dynamically trained model. The code is built in 3 primary stages.
- Face Detection
- Face Recognition
- RDP Login
-
while (True): ret, color_feed = live_capture.read() gray_feed = cv2.cvtColor(color_feed, cv2.COLOR_BGR2GRAY) face_in_feed = face_cascade.detectMultiScale(gray_feed, scaleFactor=1.3, minNeighbors=5) if len(face_in_feed) == 0: ... elif len(face_in_feed) > 3: ... else: ...
- The above snippet checks if there are any faces in the output window
color_feed
. If face(s) are found it takes respective actions using theif-elif-else
condititons.
- The above snippet checks if there are any faces in the output window
-
face_recognizer = cv2.face.LBPHFaceRecognizer_create() ... labels = {} face_recognizer.read(models_directory + 'FaceModel.yml') with open(models_directory + 'Faces.pickle', 'rb') as f: og_labels = pickle.load(f) labels = {v: k for k, v in og_labels.items()} ... ID, confidence = face_recognizer.predict(roi_gray_feed) identified = 'Matched : {}%'.format(str(round(confidence)))
- The above snippet is fundamental piece of code for identifying the face\person in the output window.
-
... os.startfile(faces_directory + labels[ID] + '\\Script\\' + labels[ID].lower() + '_rdp_login.ps1') os.startfile(binaries_directory + 'OnscreenChecker\\LoginAssist.py') ...
-
These 2 lines work upon the Remote Desktop Login and further automation using PyAutoGUI, a Python native GUI automation package. The
labels[ID].lower() + '_rdp_login.ps1'
is Sakti's RDP login script modified for that specific user. -
For example: If you create a new Face profile with name John then this file will be autogenerated as
'john_rdp_login.ps1'
with your RDP login credentials.
Thanks to Sakti's help his file dynamics can start bruteforcing his App and log the user into RDP. Once the user is logged into RDP, PyAutoGUI takes over the control usingpyautogui.locateOnScreen
command for navigating through the GUI.
-
-
Pipeline shows the scope of the project
- Planned Features
- Known Issues
-
- Converting into an executable file.
- Making the Face recognition model more robust and reliable.
- Support for password encryption in the excels files.
-
- Application tends to get slow when multiple faces are detected.
- Cannot distinguish between multiple users with same name. (Fixed)
- Code does not support ML yet.
- FaceID fails under low-lighting conditions.
-
You can find the changelog of version here.
- Latest Build
- Experimental Build
-
- Stable: 2.1
- Bug fixes, stability improvements.
- Added support for tilted face detection upto 30°.
- Facial landmarks are now slightly accurate.
- Added support for more colours.
- Face detection box now covers the entire face instead of being a square.
- Added support for .xlsx files while storing the data.
- Minor text fixes, etc.
-
- RC: 2.1.0
- Using polylines for displaying Facial Landmarks instead of dots.
-
Feel free to send pull requests and raise issues.
- Feel free to contribute to the project by mirroring another branch with distinct name so as to avoid confusions.
- Stick to minimal and simplistic approach of coding using comments wherever necessary.
- Sakti for his Powershell based Remote Desktop login app.
- Pratijeet Bhawsar and Sachin Sanap for helping develop single user detection action logic.
FaceID is an open source project licensed under GNU GPL v3.0.