def test_detect_finds_symmetra_when_present(self): detector = HeroDetector(self.__class__.fire_and_death) template = cv2.imread('src/templates/symmetra.png') points = detector.detect(template) self.assertTrue(points, 'points should not be None') self.assertFalse(detector.is_red_team(points[0][1]), 'should be on blue team')
def test_detect_finds_same_hero_on_each_team(self): detector = HeroDetector(self.__class__.full_teams) template = cv2.imread('src/templates/dva.png') points = detector.detect(template) self.assertEqual(2, len(points)) self.assertNotEqual(points[0][1], points[1][1], \ 'D.Va should be found once on each team')
def test_detect_finds_mercy_on_cards_screen(self): detector = HeroDetector(self.__class__.cards_screen) template = cv2.imread('src/templates/mercy.png') points = detector.detect(template) self.assertTrue(points, 'points should not be None') self.assertFalse(detector.is_red_team(points[0][1]), 'should be on blue team')
def test_detect_finds_mei_when_present(self): detector = HeroDetector(self.__class__.eichenwalde_full) template = cv2.imread('src/templates/mei.png') points = detector.detect(template) self.assertTrue(points, 'points should not be None') self.assertFalse(detector.is_red_team(points[0][1]), 'should be on blue team')
def test_detect_finds_lucio_when_present(self): detector = HeroDetector(self.__class__.full_teams) template = cv2.imread('src/templates/lucio.png') points = detector.detect(template) self.assertTrue(points, 'points should not be None') self.assertTrue(detector.is_red_team(points[0][1]), 'should be on red team')
def test_detect_finds_pharah_on_cards_screen(self): detector = HeroDetector(self.__class__.cards_screen2) template = cv2.imread('src/templates/pharah.png') points = detector.detect(template) self.assertTrue(points, 'points should not be None') red_pharah = points[0] blue_pharah = points[1] self.assertTrue(detector.is_red_team(red_pharah[1]), 'should be on red team') self.assertFalse(detector.is_red_team(blue_pharah[1]), 'should be on blue team')
def test_combine_points(self): points = [(1637, 357), (1638, 357), (1636, 358), (1637, 358), (1638, 358), \ (1639, 358), (1640, 358), (1636, 359), (1637, 359), (1638, 359), \ (1639, 359), (1640, 359), (1637, 360), (1638, 360), (1639, 360), \ (1640, 360), (1636, 764), (1637, 764), (1638, 764), (1639, 764), \ (1636, 765), (1637, 765), (1638, 765), (1639, 765), (1640, 765), \ (1636, 766), (1637, 766), (1638, 766), (1639, 766), (1640, 766), \ (1638, 767), (1639, 767)] expected = [(1630, 760), (1630, 350)] actual = HeroDetector.combine_points(points) self.assertEqual(expected, actual)
def test_detect_if_cards_screen(self): detector = HeroDetector(self.__class__.cards_screen) self.assertTrue(detector.is_cards_screen) detector = HeroDetector(self.__class__.full_teams) self.assertFalse(detector.is_cards_screen)
def test_is_red_team(self): detector = HeroDetector(self.__class__.full_teams) self.assertTrue(detector.is_red_team(400)) self.assertFalse(detector.is_red_team(900))
def test_constructor_detects_dimensions(self): detector = HeroDetector(self.__class__.full_teams) self.assertEqual(2560, detector.original_w) self.assertEqual(1440, detector.original_h) self.assertEqual(720, detector.mid_height)