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
35 ''' Base class for a face recognition algorithm. Output is a similarity score. '''
38
40 '''
41 Returns a list of all pairs of images in the training set that
42 are of the same person.
43 '''
44 matches = []
45 for i in range(len(self.training_data)):
46 for j in range(i+1,len(self.training_data)):
47 if i == j:
48 continue
49 if self.training_data[i][3] == self.training_data[j][3]:
50 matches.append([self.training_data[i],self.training_data[j]])
51 return matches
52
53
55 '''
56 Returns a list of all pairs in the training images that are of
57 different people.
58 '''
59 nonmatches = []
60 for i in range(len(self.training_data)):
61 for j in range(i+1,len(self.training_data)):
62 if i == j:
63 continue
64 if self.training_data[i][3] != self.training_data[j][3]:
65 nonmatches.append([self.training_data[i],self.training_data[j]])
66 return nonmatches
67
68 - def addTraining(self,img,rect=None,eyes=None,sub_id=None):
69 '''Adds a training face for the algorithm.'''
70 self.training_data.append([img,rect,eyes,sub_id])
71
72
74 '''Compute the similarity of two faces'''
75 raise NotImplementedError()
76
77
79 '''
80 Given an image and face location, compute a face record.
81
82 @param im: image containing the face
83 @param rect: specifies the location of the face in the image, and is
84 typically defined as a detection rectangle or eye coordinates.
85
86 @returns: data that represents the identity of the face, such as
87 eigen coeffecients for PCA.
88 '''
89
90 raise NotImplementedError()
91