-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncodeGenerator.py
More file actions
35 lines (28 loc) · 806 Bytes
/
Copy pathEncodeGenerator.py
File metadata and controls
35 lines (28 loc) · 806 Bytes
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
32
33
34
35
import cv2
import face_recognition
import os
import pickle
folderPath = "Images"
pathList = os.listdir(folderPath)
imgList=[]
idList=[]
for path in pathList:
imgList.append(cv2.imread(os.path.join(folderPath,path)))
idList.append(os.path.splitext(path)[0])
print(imgList)
print(idList)
def findEncodings(imageList):
encodeList=[]
for img in imageList:
imgRGB = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
encode = face_recognition.face_encodings(img)[0]
encodeList.append(encode)
return encodeList
print("Encoding Started")
encodeListKnown = findEncodings(imgList)
encodeListKnownWithIDS = [encodeListKnown,idList]
print("Encoding Finally")
file = open("EncodeFile.p","wb")
pickle.dump(encodeListKnownWithIDS,file)
file.close()
print("File Saved")