-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
57 lines (47 loc) · 1.64 KB
/
util.py
File metadata and controls
57 lines (47 loc) · 1.64 KB
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
47
48
49
50
51
52
53
54
55
56
57
from configuration import PERSON_GROUP_ID
import cognitive_face_wrapper.person as CF_person
import graphics
class Person:
def __init__(self, personId, name, userData):
self.id = personId
self.name = name
self.userData = userData
self.persistedFaceIds = []
print ("Created new person with id", self.id)
def setPersistedFaceIds(self, persistedFaceIds):
self.persistedFaceIds = persistedFaceIds
def addFaceId(self, faceId):
# has not reached maximum # of faces per person
if len(self.persistedFaceIds) < 248:
# add face id to face id list
# add persisted face on azure
img = graphics.openFaceImage(faceId + '.jpg')
imgBin = graphics.convertToBinary(img)
addFaceOutput = CF_person.add_face(imgBin, PERSON_GROUP_ID, self.id)
persistedFaceId = addFaceOutput['persistedFaceId']
self.persistedFaceIds.append(persistedFaceId)
graphics.savePersistedFaceImage(persistedFaceId + '.jpg', img)
else:
print ("Exceeded limit for # of persisted face ids for %s" % self.id)
def getImage(self):
filename = self.persistedFaceIds[0] + '.jpg'
return graphics.openPersistedFaceImage(filename)
# # person groups {personGroupId: list of Person}
# personGroups = {
# 'bad': [],
# 'neutral': [],
# 'good': [],
# 'test': []
# }
# labels
BAD = 'bad'
NEUTRAL = 'neutral'
GOOD = 'good'
TEST = 'test'
# directory of created Persons {personId: Person}
people = {}
# # list of Person for each label
# badPeople = []
# neutralPeople = []
# goodPeople = []
# testPeople = []