import face_recognition
import os
from os import listdir
from os.path import isfile, join
import sys
import time
import cv2
import numpy
import array
import glob
import errno
import cv2
import random



def getReferences(dir):
    subdirs=listdir(dir) 
    names=[];
    emb=[]
    for subdir in (subdirs):
        name=subdir
        subdir=join(dir,subdir)
        files=[f for f in listdir(subdir) if isfile(join(subdir,f))]
        for file in (files):
            file=join(subdir,file);
            image = face_recognition.load_image_file(file)
            encodings=face_recognition.face_encodings(image)
            if (encodings):
                names.append(name)
                emb.append(encodings[0])
    return emb,names

def main(args,distance):
    subdirs=listdir(args) 
    features=[];
    names=[];
    
    for subdir in (subdirs):
        name=subdir
        subdir=join(args,subdir)
        files=[f for f in listdir(subdir) if isfile(join(subdir,f))]
        txtFile = open('./symptoms.txt', 'a') 
        for file in (files):
            file=join(subdir,file);
            image = face_recognition.load_image_file(file)
            align=face_recognition.face_landmarks(image)
            encodings=face_recognition.face_encodings(image)
            for encoding in (encodings):
                output = encoding
                txtFile.write("%s\n" % output)
            print("File", file)
            print("Original value: ", output)
        
if __name__=="__main__":
	sys.exit(int(main("./Test_image_database_fromLFW/",0.55)) or 0)