import base64
import pickle
import time
import threading
import os
RESULT=""
def person_create(person_name,person_photo_directory,person_photo_file_path):
filepath=os.path.join(person_photo_directory,person_photo_file_path)
try:
with open(filepath, "rb") as file:
encoded=base64.b64encode(file.read())
except IOError as err:
alert("File path is wrong!")
raise ValueError("File path is wrong")
person = service_person_create(person_name, "persons", "1980-01-01", 1,encoded, 10)
if type(person) is dict:
t = threading.Thread(target=person_enroll, args=(person,))
t.daemon = True
t.start()
b=t.join()
host.stats()["run_count"] += 1
else:
return "Fail!"
if (type(RESULT) is dict) and RESULT["person_guid"]==person["person_guid"]:
return "Ok!"
else: return ("Fail! Result is: %s"%RESULT)
def person_enroll(person):
global RESULT
time.sleep(3)
RESULT=service_fr_person_enroll(person["person_guid"], 10)
add_function_call_http_handler("person_create", settings("face_recognizer"), person_create)