Update Facial Recognition codes
|
@ -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!
|
||||||
|
|
|
@ -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):
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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()
|
||||||
|
|
BIN
Facial_images/face_rec/train/xunzhe wen/0.jpg
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/1.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/10.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/11.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/12.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/13.jpg
Normal file
After Width: | Height: | Size: 81 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/14.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/15.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/16.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/17.jpg
Normal file
After Width: | Height: | Size: 81 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/18.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/19.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/2.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/20.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/21.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/22.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/23.jpg
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/24.jpg
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/25.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/26.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/27.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/28.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/29.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/3.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/30.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/31.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/32.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/33.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/34.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/35.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/36.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/37.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/38.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/39.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/4.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/40.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/41.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/42.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/43.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/44.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/45.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/46.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/47.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/48.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/49.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/5.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/6.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/7.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/8.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Facial_images/face_rec/train/xunzhe wen/9.jpg
Normal file
After Width: | Height: | Size: 83 KiB |