-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathface_map.py
27 lines (22 loc) · 838 Bytes
/
face_map.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
class FaceMap:
def __init__(self):
self.face_map = {}
def addFace(self, faceId, name):
self.face_map[faceId] = name
print "Added: ", name, "->", faceId
def getFaceIds(self):
return list(self.face_map.keys())
def getInvertedMap(self):
return {name : faceId for faceId, name in self.face_map.iteritems()}
def getFaceMapsFromGroups(self, groups=None):
inverted = self.getInvertedMap()
result = []
if groups:
# each group has its own face map
for group in groups:
result.append({inverted[name] : name for name in group})
else:
# present each face as its own group
for faceId, name in self.face_map.iteritems():
result.append({faceId : name})
return result