From 0406c17163091bf3ff85880e866a0b76e5450699 Mon Sep 17 00:00:00 2001
From: Yasmine Moumou <yasmine.moumou@polymtl.ca>
Date: Sat, 7 Nov 2020 11:59:14 -0500
Subject: [PATCH] Update

---
 .../armor_color/baseline_experiments.py       |  4 +-
 .../dataset/armor_lines_detector.py           | 46 ++++++++++---------
 2 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/robots-at-robots/research/robots_at_robots/armor_color/baseline_experiments.py b/robots-at-robots/research/robots_at_robots/armor_color/baseline_experiments.py
index c0ab8de..d723c68 100644
--- a/robots-at-robots/research/robots_at_robots/armor_color/baseline_experiments.py
+++ b/robots-at-robots/research/robots_at_robots/armor_color/baseline_experiments.py
@@ -13,8 +13,8 @@ if __name__ == "__main__":
     logging.getLogger().setLevel("INFO")
 
     reporter = ArmorColorPipelineReporterFactory.from_roco_datasets(
-        train_roco_datasets=[ROCODatasetsZoo.TWITCH.T470151286, ROCODatasetsZoo.TWITCH.T470150052],
-        test_roco_datasets=[ROCODatasetsZoo.TWITCH.T470152289],
+        train_roco_datasets=[ROCODatasetsZoo.TWITCH.T470149568],
+        test_roco_datasets=[ROCODatasetsZoo.TWITCH.T470149568],
     )
 
     red_blue_comparison_pipeline = ClassifierImagePipeline(
diff --git a/robots-at-robots/research/robots_at_robots/dataset/armor_lines_detector.py b/robots-at-robots/research/robots_at_robots/dataset/armor_lines_detector.py
index ccc62cd..d472b70 100644
--- a/robots-at-robots/research/robots_at_robots/dataset/armor_lines_detector.py
+++ b/robots-at-robots/research/robots_at_robots/dataset/armor_lines_detector.py
@@ -1,13 +1,17 @@
+from itertools import islice
 from typing import Tuple
 
 import cv2
 import numpy as np
 import matplotlib.pyplot as plt
+
+from dataset.armor_dataset_factory import ArmorDataset
 from polystar.common.models.image import Image
 
 from polystar.common.models.image_annotation import ImageAnnotation
-from research.common.dataset.twitch.twitch_roco_datasets import TwitchROCODataset
-from research.robots_at_robots.dataset.armor_dataset_factory import ArmorDatasetFactory
+#from research.common.dataset.twitch.twitch_roco_datasets import TwitchROCODataset
+#from research.robots_at_robots.dataset.armor_dataset_factory import ArmorDatasetFactory
+from research.common.datasets.roco.zoo.roco_dataset_zoo import ROCODatasetsZoo
 
 
 class ArmorLinesDetector:
@@ -15,8 +19,9 @@ class ArmorLinesDetector:
     #line detection
     @staticmethod
     def detect_lines(image: Image) -> Image:
-        edges = cv2.Canny(image,  100, 200)
-        lines = cv2.HoughLines(edges, 1, np.pi / 180, 50)
+
+        edges = cv2.Canny(image,  50, 200)
+        lines = cv2.HoughLines(edges, 1, np.pi / 180, threshold=25)
         return lineDetector.draw_lines(image, lines)
 
     # Drawing lines on image
@@ -35,7 +40,7 @@ class ArmorLinesDetector:
             x2 = int(x0 - 1000 * (-b))
             y2 = int(y0 - 1000 * (a))
 
-            cv2.line(image_lines, (x1, y1), (x2, y2), (0, 0, 255), 2)
+            cv2.line(image_lines, (x1, y1), (x2, y2), (0, 0, 255), 1)
 
         return image_lines
 
@@ -46,19 +51,18 @@ if __name__ == "__main__":
 
     lineDetector = ArmorLinesDetector()
     armor_lines = []
-    for i, (armor_img, armor, k, p) in enumerate(ArmorDatasetFactory.from_dataset(TwitchROCODataset.TWITCH_470158483)):
-        armor_lines[i] = lineDetector.detect_lines(armor_img)
-   # test = cv2.imread('test.png')  # ouverture
-   # test = cv2.cvtColor(test, cv2.COLOR_BGR2RGB)  # conversion des couleurs
-   # armor_lines = lineDetector.detect_lines(test)
-   # plt.imshow(armor_lines[7], cmap='gray')
-   # plt.title('50 lignes principales')
-   # plt.show()
-
-    for armor in enumerate(armor_lines):
-        plt.imshow(armor)
-        plt.show()
-        plt.clf()
-
-        if i == 5:
-            break
\ No newline at end of file
+    for _armor_img, _armor, _name in islice(ArmorDataset(ROCODatasetsZoo.TWITCH.T470149568.to_images()), 20, 30):
+       # armor_lines = lineDetector.detect_lines(_armor_img)
+        #print(_name, repr(_armor))
+        #plt.imshow(armor_lines)
+        #plt.show()
+        #plt.clf()
+
+
+     test = cv2.imread(r'C:\Users\moumo\Documents\polySTAR\code\dataset\twitch\v1\470149568\colors\470149568-frame-001120-0-red.jpg')  # ouverture
+     test = cv2.cvtColor(test, cv2.COLOR_BGR2RGB)  # conversion des couleurs
+     armor_lines = lineDetector.detect_lines(test)
+     plt.imshow(armor_lines, cmap='gray')
+     plt.title('50 lignes principales')
+     plt.show()
+     plt.clf()
\ No newline at end of file
-- 
GitLab