Update Facial Recognition codes

This commit is contained in:
Feier Zhang 2021-01-23 19:00:51 -05:00
parent 0e0c1d2ce8
commit 3858390bf6
57 changed files with 24 additions and 24 deletions

View file

@ -28,7 +28,7 @@ So to run the demo, we need to install Dlib on our system.
3. Requirements for face registration: 3. Requirements for face registration:
a. User can sometimes turn your head a little bit to let us get more face data, but you must make sure that there're 5 colles on each photo. a. User can sometimes slightly rotate their face, but must make sure their facical features (mouth, eyes, nose...) are within the camera view.
b. Don't register you face when too much light is coming. b. Ambient light could affect the performance of the facial detection, such as overexposure, glare, reflection or so on;
welcome any try-out and comments! welcome any try-out and comments!

View file

@ -43,12 +43,12 @@ def enroll_face_dataset():
i = 0 i = 0
faceDescriptors = None faceDescriptors = None
for imagePath in imagePaths: for imagePath in imagePaths:
print("processing: {}".format(imagePath)) #print("processing: {}".format(imagePath))
img = cv2.imread(imagePath) img = cv2.imread(imagePath)
faces = faceDetector(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) faces = faceDetector(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
print("{} Face(s) found".format(len(faces))) #print("{} Face(s) found".format(len(faces)))
for k, face in enumerate(faces): for k, face in enumerate(faces):

View file

@ -13,7 +13,7 @@ pwd = sys.path[0]
PREDICTOR_PATH = pwd + '/Facial_models/shape_predictor_68_face_landmarks.dat' PREDICTOR_PATH = pwd + '/Facial_models/shape_predictor_68_face_landmarks.dat'
FACE_RECOGNITION_MODEL_PATH = pwd + '/Facial_models/dlib_face_recognition_resnet_model_v1.dat' FACE_RECOGNITION_MODEL_PATH = pwd + '/Facial_models/dlib_face_recognition_resnet_model_v1.dat'
SKIP_FRAMES = 10 SKIP_FRAMES = 1
THRESHOLD = 0.4 THRESHOLD = 0.4
faceDetector = dlib.get_frontal_face_detector() faceDetector = dlib.get_frontal_face_detector()
@ -25,9 +25,10 @@ faceDescriptorsEnrolled = np.load(pwd+'/Facial_models/descriptors.npy')
cam = cv2.VideoCapture(1) cam = cv2.VideoCapture(1)
count = 0 count = 0
x1 = x2 = y1 = y2 = 0
while True: while True:
t = time.time() t = time.time()
success, im = cam.read() success, im = cam.read()
@ -72,16 +73,10 @@ while True:
else: else:
label = 'unknown' label = 'unknown'
print("time taken = {:.3f} seconds".format(time.time() - t)) #print("time taken = {:.3f} seconds".format(time.time() - t))
cv2.rectangle(im, (x1, y1), (x2, y2), (0, 255, 0), 2) cv2.rectangle(im, (x1, y1), (x2, y2), (0, 255, 0), 2)
#center = (int((x1 + x2)/2.0), int((y1 + y2)/2.0))
#radius = int((y2-y1)/2.0)
#color = (0, 255, 0)
#cv2.circle(im, center, radius, color, thickness=1, lineType=8, shift=0)
font_face = cv2.FONT_HERSHEY_SIMPLEX font_face = cv2.FONT_HERSHEY_SIMPLEX
font_scale = 0.8 font_scale = 0.8
text_color = (0, 255, 0) text_color = (0, 255, 0)

View file

@ -4,7 +4,6 @@ import math
import cv2 import cv2
import Facial_Recognition_Enrollment import Facial_Recognition_Enrollment
def register_your_face(label): def register_your_face(label):
num_cap = 50 num_cap = 50
@ -32,6 +31,12 @@ def register_your_face(label):
if __name__ == "__main__": if __name__ == "__main__":
label = input('Enter a label: ') print("Face registration start...")
print()
label = input('Pleas enter your Name/Label: ')
register_your_face(label) register_your_face(label)
Facial_Recognition_Enrollment.enroll_face_dataset() print("Data saved! Starting enrollment...")
print()
Facial_Recognition_Enrollment.enroll_face_dataset() #Need discuss and modify after intergrate with database.
print("Face registration completed!")
print()

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Binary file not shown.