-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkairos-enroll.py
38 lines (34 loc) · 904 Bytes
/
kairos-enroll.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
32
33
34
35
36
37
38
import photos
import requests
import io
import base64
import json
img = photos.capture_image()
def getPhoto():
with io.BytesIO() as output:
#img = photos.capture_image()
img.save(output, 'JPEG')
contents = output.getvalue()
image = base64.b64encode(contents)
return image
def enrollPhoto():
subject_id = raw_input("Hello, What is your name: ? ")
print("Thank you " + subject_id + "." + " Analyzing...")
image = getPhoto()
url = "https://api.kairos.com/enroll"
values = {
'image': image,
'subject_id': subject_id,
'gallery_name': 'test'
}
headers = {
'Content-Type': 'application/json',
'app_id': '*****************',
'app_key': '**********************'
}
r = requests.post(url, data=json.dumps(values), headers = headers)
parsed_json = json.loads(r.content)
attr = parsed_json['images'][0]['attributes']
img.show()
print(json.dumps(attr, indent=2))
enrollPhoto()