class DetectionIle(TestCase):
    def setUp(self):
        self.analyseImageWorld = AnalyseImageWorld()
        self.analyseImageWorld.chargerImage("images/table2/detection1.png")
        self.detection = DetectionIles(self.analyseImageWorld.image, 2)

    def test_detecter(self):
        self.detection.detecter()
        nombreTresor = len(self.detection.ilesIdentifiees)

        self.assertEqual(nombreTresor, 16)

    def test_trouverContourIles(self):
        c, h = self.detection.trouverContoursIles("Rouge")
        bool = len(c) >= 4

        self.assertTrue(bool)

    def test_trouverIles(self):
        c, h = self.detection.trouverContoursIles("Rouge")
        self.detection.trouverIles(c, h, "Rouge")
        bool = len(self.detection.ilesIdentifiees) == len(c)

        self.assertTrue(bool)

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

        self.assertTrue(bool)
    def trouverIles(self):
        print("\nDetection des iles...")
        detectionMultipleIles = []

        for i in range(NB_DETECTION_TOT):
            print 'detection: %d sur 20' % i
            self.chargerImage()
            detectionIles = DetectionIles(self.image, self.stationBase.getNumTable())
            detectionIles.detecter()
            listIles = self.eliminerContoursProcheRobot(detectionIles.getIlesIdentifiees())
            detectionMultipleIles.append(listIles)
            time.sleep(0.01)

        listIles = self.resultatPlusCommun(detectionMultipleIles)
        self.stationBase.carte.setIles(listIles)
 def setUp(self):
     self.analyseImageWorld = AnalyseImageWorld()
     self.analyseImageWorld.chargerImage("images/table2/detection1.png")
     self.detection = DetectionIles(self.analyseImageWorld.image, 2)
 def setUp(self):
     self.image = self.imageCamera = cv2.imread(
         ConfigPath.Config().appendToProjectPath('images/table2/detection1.png'))
     self.detectionElements = DetectionIles(self.image)
class TestDetectionElementsCartographiques(TestCase):
    def setUp(self):
        self.image = self.imageCamera = cv2.imread(
            ConfigPath.Config().appendToProjectPath('images/table2/detection1.png'))
        self.detectionElements = DetectionIles(self.image)

    def test_detecte_bon_nombre_de_formes_jaune(self):
        self.detectionElements.detecter()
        nombreJaune = self.detectionElements._getNombreIleCouleur("Jaune")
        self.assertEqual(nombreJaune, 4)

    def test_detecte_bon_nombre_de_formes_bleue(self):
        self.detectionElements.detecter()
        nombreBleu = self.detectionElements._getNombreIleCouleur("Bleu")
        self.assertEqual(nombreBleu, 4)

    def test_detecte_bon_nombre_de_formes_verte(self):
        self.detectionElements.detecter()
        nombreVert = self.detectionElements._getNombreIleCouleur("Vert")
        self.assertEqual(nombreVert, 4)

    def test_detecte_bon_nombre_de_formes_rouge(self):
        self.detectionElements.detecter()
        nombreRouge = self.detectionElements._getNombreIleCouleur("Rouge")
        self.assertEqual(nombreRouge, 4)

    def test_detecte_bon_nombre_tresor(self):
        self.detectionElements.detecterTresor()
        tresors = self.detectionElements.tresorIdentifies
        self.assertEqual(len(tresors), 3)