Commit a5818969 authored by Odhara Kodikara's avatar Odhara Kodikara

prepare encoding function added

parent 75c922eb
......@@ -85,12 +85,32 @@ def facial_recognition():
cv2.imshow("Frame", image)
cv2.waitKey(0)
def prepare_enc():
imagePaths = list(paths.list_images('Images'))
knownEncodings = []
knownNames = []
for (i, imagePath) in enumerate(imagePaths):
name = imagePath.split(os.path.sep)[-2]
image = cv2.imread(imagePath)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
boxes = face_recognition.face_locations(rgb,model='hog')
encodings = face_recognition.face_encodings(rgb, boxes)
for encoding in encodings:
knownEncodings.append(encoding)
knownNames.append(name)
data = {"encodings": knownEncodings, "names": knownNames}
f = open("face_enc", "wb")
f.write(pickle.dumps(data))
f.close()
def main(argv):
if (len(sys.argv) > 0):
# Check if Arguments Exist
for i, arg in enumerate(sys.argv):
if arg == "new":
print("New Face Recogniser")
prepare_enc()
found = face_detection()
print(found)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment