https://github.com/bertandogancay/webcam-face-recognition
A face recognition system that can detect faces and differentiate them based on the category they are in.
https://github.com/bertandogancay/webcam-face-recognition
face face-detection face-recognition jetson-nano opencv opencv-python real-time
Last synced: 2 months ago
JSON representation
A face recognition system that can detect faces and differentiate them based on the category they are in.
- Host: GitHub
- URL: https://github.com/bertandogancay/webcam-face-recognition
- Owner: BertanDogancay
- Created: 2022-08-24T16:27:06.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-22T07:26:19.000Z (about 3 years ago)
- Last Synced: 2025-03-23T07:14:58.214Z (about 1 year ago)
- Topics: face, face-detection, face-recognition, jetson-nano, opencv, opencv-python, real-time
- Language: C++
- Homepage:
- Size: 6.3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Webcam-Face-Recognition
This is a face recognition system that allows you to categorize people based on their access status, These categories are (Access) and (No Access). Image 1 folder is for people that have access and Image 2 folder is for people that do not have access. If you put the picture of your face in Image 1 folder you will see a green box covering your face on the camera, and if you put it in Image 2 folder, you will see a red box with a text on top that says "FAIL" on it.
Access
No Access
In this code, the face_recognition library was used to detect faces. Check out their repo for more information. The link is [here](https://github.com/ageitgey/face_recognition). This code can be run on any kind of platform and computer, but for better performance in detections, you need a cuda enabled dlib library. When you try to import face_recognition library it will also import dlib automatically, but it might not be compiled with cuda depending on the system you have and whether or not if cuda is already installed on your computer.
As can be seen in the table below, there are two different pictures of the same person and even though these pictures were taken in different times and the hair styles are not very similar, the detections and results are very accurate. when the code is exacuted, there will be a number between 0 and 1 that changes constantly and printed on the command prompt. That number is "faceDisAccess" or "faceDisNoAccess". The number is closer to zero, the better the accurracy of the results.
Here is how they are being calculated;
``` python
faceDisAccess = face_recognition.face_distance(encodeListAccess, encodeFace)
faceDisNoAccess = face_recognition.face_distance(encodeListNoAccess, encodeFace)
```
Pose 1
Pose 2
***NOTE: This example includes a pan tilt mechanism and was designed to be used in devices like Raspberry pi or Jetson Nano, but if the code is exacuted on a regular computer, it will still work without any problem, but the camera won't move in the face's direction.***
If you are using a regular computer or do not include servo motors in your project, you can disregard these lines of codes;
``` python
import board
import busio
import os
from adafruit_servokit import ServoKit
i2c = busio.I2C(board.SCL, board.SDA)
import adafruit_pca9685
pwm = adafruit_pca9685.PCA9685(i2c)
pwm.frequency = 50
pwm = ServoKit(channels=16)
pwm.servo[0].angle = 90
x_medium = int(cols / 2)
y_medium = int(cols / 2)
center = int(cols / 2)
position1 = 90
if x_medium < center -70:
position1 += 3
elif x_medium > center +70:
position1 -= 3
pwm.servo[0].angle = position1
```