def setUp(self): # fpaths = ['data/MatthewM0.jpg', 'data/MatthewM1.jpg'] fpath = 'data/MatthewM0.jpg' # urlpaths = ['http://az696524.vo.msecnd.net/fireflymobileappblobcontainer/C222B9C18560DD53312FBAE1D027C107.jpg'] urlpath = 'http://az696524.vo.msecnd.net/fireflymobileappblobcontainer/C222B9C18560DD53312FBAE1D027C107.jpg' self.flfile=FL(fpath) self.dfl = DFL(fpath) self.flurl=FL(urlpath)
class FaceLandMarksTest(unittest.TestCase): def setUp(self): # fpaths = ['data/MatthewM0.jpg', 'data/MatthewM1.jpg'] fpath = 'data/MatthewM0.jpg' # urlpaths = ['http://az696524.vo.msecnd.net/fireflymobileappblobcontainer/C222B9C18560DD53312FBAE1D027C107.jpg'] urlpath = 'http://az696524.vo.msecnd.net/fireflymobileappblobcontainer/C222B9C18560DD53312FBAE1D027C107.jpg' self.flfile=FL(fpath) self.dfl = DFL(fpath) self.flurl=FL(urlpath) def test_landmarks(self): assert len(self.flfile.landmarks) == 68 assert len(self.flurl.landmarks) == 68 assert np.array_equal(self.dfl.landmarks, self.flfile.landmarks) def test_demo(self): self.dfl.show_landmarks('test_demo') def test_get(self): for part in FL._parts: assert len(self.dfl.get(part))==len(FL.__dict__['_'+part]) def test_annotate(self): self.dfl.annotate_landmarks() for triple in FL._hor: for tup in triple: self.dfl.add_annotate([self.dfl.coor(*tup)]) self.dfl.add_annotate([self.dfl.coor('mouth', 'left')]) self.dfl.show_all('add_annotate') def test_coor(self): top_face = self.dfl.coor('face','top') assert np.array_equal(top_face, self.dfl.coor('left_brow','top')) or np.array_equal(top_face, self.dfl.coor('right_brow','top')) def test_ratio(self): for triple in FL._vert: ratio = self.flfile.ratio_vert(*triple) print('%s vertical ratio is %f'%(triple, ratio)) assert ratio > 0 and ratio < 1 for triple in FL._hor: ratio = self.flfile.ratio_hor(*triple) print('%s horizonal ratio is %f'%(triple, ratio)) assert ratio > 0 and ratio < 1