class DetectionRbot(TestCase):
    def setUp(self):
        self.analyseImageWorld = AnalyseImageWorld()
        self.analyseImageWorld.chargerImage('images/table2/robotTest1.png')
        self.detection = DetectionRobot(self.analyseImageWorld.image, 2)

    def test_detecter(self):
        self.detection.detecter()

        self.assertIsNotNone(self.detection.robotIdentifiee)

    def test_trouverContoursRobot(self):
        c, h = self.detection.trouverContoursRobot()
        bool = len(c) >= 2

        self.assertTrue(bool)

    def test_trouverRobot(self):
        c, h = self.detection.trouverContoursRobot()
        c = self.detection.eleminerCoutoursNegligeable(c, h)
        self.detection.trouverRobot(c)

        self.assertIsNotNone(self.detection.robotIdentifiee)

    def test_eleminerCoutoursNegligeable(self):
        c, h = self.detection.trouverContoursRobot()
        c2 = self.detection.eleminerCoutoursNegligeable(c, h)
        bool = len(c2) <= len(c)

        self.assertTrue(bool)
 def trouverRobot(self):
     detectionRobot = DetectionRobot(self.image, self.stationBase.getNumTable())
     detectionRobot.detecter()
     robot = detectionRobot.getRobot()
     if robot is not None :
         if self.stationBase.getCarte().getRobot() is None:
             self.stationBase.getCarte().setRobot(robot)
         elif self.deplacementPlausible(robot.getCentre()):
             self.stationBase.getCarte().setRobot(robot)
             self.cntRobotPerdu = 0
         elif self.cntRobotPerdu > MAX_CNT_ROBOT_PERDU:
             self.cntRobotPerdu = 0
             self.stationBase.getCarte().setRobot(None)
         else:
             self.cntRobotPerdu += 1
     elif self.cntRobotPerdu > MAX_CNT_ROBOT_PERDU:
             self.stationBase.getCarte().setRobot(None)
             self.cntRobotPerdu = 0
     else:
         self.cntRobotPerdu += 1
 def setUp(self):
     self.analyseImageWorld = AnalyseImageWorld()
     self.analyseImageWorld.chargerImage('images/table2/robotTest1.png')
     self.detection = DetectionRobot(self.analyseImageWorld.image, 2)