-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (35 loc) · 1.39 KB
/
main.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
39
40
41
42
43
44
45
46
import cognitive_face as CF
from PIL import Image
import json
import time
KEY = 'd362531db61f41728ebff0e734b80fc1' # Replace with a valid Subscription Key here.
CF.Key.set(KEY)
BASE_URL = 'https://westcentralus.api.cognitive.microsoft.com/face/v1.0' # Replace with your regional Base URL
CF.BaseUrl.set(BASE_URL)
#img_url = 'https://raw.githubusercontent.com/Microsoft/Cognitive-Face-Windows/master/Data/detection1.jpg'
#test = Image.open("test/output_00001.jpg")
#path = "test/output_00002.jpg"
master_result = {}
time_factor = 10
folder = "aj"
for i in range(1,130):
if len(str(i)) < 2:
path = folder + "/output_0000" + str(i) + ".jpg"
elif len(str(i)) < 3:
path = folder + "/output_000" + str(i) + ".jpg"
elif len(str(i)) < 4:
path = folder + "/output_00" + str(i) + ".jpg"
elif len(str(i)) < 5:
path = folder + "/output_0" + str(i) + ".jpg"
timestamp = (i - 1) * time_factor
attributes = (
'age,gender,headPose,smile,facialHair,glasses,emotion,hair,'
'makeup,occlusion,accessories,blur,exposure,noise')
result = CF.face.detect(path, False, False, attributes)
master_result[str(timestamp)] = result
print("Sleeping now at: " + str(i))
time.sleep(4)
#result = CF.face.detect("test/output_00001.jpg")
print(master_result)
with open('data.json', 'w') as outfile:
json.dump(master_result, outfile)