def similarity(self,fir1,fir2):
'''Compute the similarity of two faces'''
assert self.trained == True
if self.measure == PCA_L1:
return (scipy.abs(fir1-fir2)).sum()
if self.measure == PCA_L2:
return scipy.sqrt(((fir1-fir2)*(fir1-fir2)).sum())
if self.measure == PCA_COS:
return (fir1*fir2).sum()
raise NotImplementedError("Unknown distance measure: %d"%self.measure)
评论列表
文章目录