forked from aesaganda/Smart-Camera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathegit.py
31 lines (26 loc) · 836 Bytes
/
egit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import cv2
import face_recognition as FR
import pickle
print(cv2.__version__)
encodings = []
names = []
#imageDir = r"C:\Users\AFSAR\PycharmProjects\Akıllı Kamera\Akıllı Kamera\demoImages\known"
imageDir = r"demoImages\known"
for root, dirs, files in os.walk(imageDir):
print(root)
print(dirs)
print(files)
for file in files:
# print(file)
fullFilePath = os.path.join(root, file)
print(fullFilePath)
myPicture = FR.load_image_file(fullFilePath)
encoding = FR.face_encodings(myPicture)[0]
# [0] added here because of array logic
name = os.path.splitext(file)[0]
encodings.append(encoding)
names.append(name)
with open("train.pkl", "wb") as f:
pickle.dump(names, f)
pickle.dump(encodings, f)