2020-11-08 21:57:59 +00:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import math
|
|
|
|
import cv2
|
2021-01-19 22:08:55 +00:00
|
|
|
import Facial_Recognition_Enrollment
|
2020-11-08 21:57:59 +00:00
|
|
|
|
|
|
|
|
2020-11-14 17:28:50 +00:00
|
|
|
def register_your_face(label):
|
2021-01-19 22:08:55 +00:00
|
|
|
num_cap = 50
|
2020-11-08 21:57:59 +00:00
|
|
|
|
2020-11-14 17:28:50 +00:00
|
|
|
path = sys.path[0] + '/Facial_images/face_rec/train/' + label
|
2020-11-08 21:57:59 +00:00
|
|
|
|
2020-11-14 17:28:50 +00:00
|
|
|
folder = os.path.exists(path)
|
2020-11-08 21:57:59 +00:00
|
|
|
|
2020-11-14 17:28:50 +00:00
|
|
|
if not folder:
|
|
|
|
os.makedirs(path)
|
2020-11-08 21:57:59 +00:00
|
|
|
|
2021-01-19 22:08:55 +00:00
|
|
|
cap = cv2.VideoCapture(1)
|
2020-11-14 17:28:50 +00:00
|
|
|
c = 0
|
|
|
|
while c < num_cap:
|
|
|
|
ret, frame = cap.read()
|
2020-11-08 21:57:59 +00:00
|
|
|
|
2020-11-14 17:28:50 +00:00
|
|
|
cv2.imshow("capture", frame)
|
2020-11-08 21:57:59 +00:00
|
|
|
|
2020-11-14 17:28:50 +00:00
|
|
|
cv2.imwrite(path + '/' + str(c) + '.jpg', frame)
|
2020-11-08 21:57:59 +00:00
|
|
|
|
2020-11-14 17:28:50 +00:00
|
|
|
c = c + 1
|
|
|
|
cv2.waitKey(500)
|
2020-11-08 21:57:59 +00:00
|
|
|
|
2020-11-14 17:28:50 +00:00
|
|
|
cap.release()
|
|
|
|
cv2.destroyAllWindows()
|
2020-11-18 02:56:47 +00:00
|
|
|
|
2021-01-09 10:44:53 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-01-19 22:08:55 +00:00
|
|
|
label = input('Enter a label: ')
|
2021-01-09 10:44:53 +00:00
|
|
|
register_your_face(label)
|
2021-01-19 22:08:55 +00:00
|
|
|
Facial_Recognition_Enrollment.enroll_face_dataset()
|