From 32f71cdec7ccac7d3ea0ac4052ba35dffd56cfa0 Mon Sep 17 00:00:00 2001
From: "simon.fanetti" <simon.fanetti@etu.hesge.ch>
Date: Wed, 8 Jul 2020 16:10:22 +0200
Subject: [PATCH] fixed xrandr parsing

---
 app/SandboxSetup/SandboxSetup.pro  | 1 -
 app/SandboxSetup/monitorgui.cpp    | 2 +-
 app/SandboxSetup/projectiongui.cpp | 6 +++++-
 app/SandboxSetup/projectiongui.ui  | 6 ++++--
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/app/SandboxSetup/SandboxSetup.pro b/app/SandboxSetup/SandboxSetup.pro
index a699d0a..7af29b7 100644
--- a/app/SandboxSetup/SandboxSetup.pro
+++ b/app/SandboxSetup/SandboxSetup.pro
@@ -63,7 +63,6 @@ FORMS += \
     saveconfiggui.ui
 
 
-
 INCLUDEPATH += ../../inc
 
 LIBS += -L"../../build" -lsandbox -lrealsense2 -lyaml-cpp
diff --git a/app/SandboxSetup/monitorgui.cpp b/app/SandboxSetup/monitorgui.cpp
index 124b7dd..d2dbd2a 100644
--- a/app/SandboxSetup/monitorgui.cpp
+++ b/app/SandboxSetup/monitorgui.cpp
@@ -84,7 +84,7 @@ void MonitorGui::on_cbxOutputs_currentIndexChanged(int index)
 void MonitorGui::initMonitorMapWithFile(std::string path){
 
     // Save in file the monitors and their resolutions
-    int err = system( ("xrandr -d :0 | sed -n '1!p' > " + path).c_str() );
+    int err = system( ("xrandr | sed -n '1!p' > " + path).c_str() );
     if(err){
         std::cout << "Couldn't get screens and their resolutions" << std::endl;
         exit(err);
diff --git a/app/SandboxSetup/projectiongui.cpp b/app/SandboxSetup/projectiongui.cpp
index bcc5422..9242200 100644
--- a/app/SandboxSetup/projectiongui.cpp
+++ b/app/SandboxSetup/projectiongui.cpp
@@ -53,7 +53,11 @@ void ProjectionGui::refreshFrame(){
 void ProjectionGui::startCapture(){
     if(!cameraUsed){
         // open blue screen on the selected output
-        cv::Mat blue = cv::Mat(1, 1, CV_8UC3, cv::Scalar(0, 0, 255));
+        setup->getCamera()->capture();
+        cv::Mat rgb = setup->getCamera()->getColorFrame();
+        cv::Size sz = rgb.size();
+        cv::Mat blue = cv::Mat(sz.height, sz.width, CV_8UC3, cv::Scalar(0, 0, 255));
+        cv::circle(blue, cv::Point(sz.width/2, sz.height/2), sz.height*2/100, cv::Scalar(255,0,0), CV_FILLED, 8,0);
         blueScreen->editGeometry(mg->getResolution());
         blueScreen->imShow(blue);
         cameraUsed = true;
diff --git a/app/SandboxSetup/projectiongui.ui b/app/SandboxSetup/projectiongui.ui
index 0af5fca..41e07ba 100644
--- a/app/SandboxSetup/projectiongui.ui
+++ b/app/SandboxSetup/projectiongui.ui
@@ -51,7 +51,7 @@
      <x>30</x>
      <y>370</y>
      <width>581</width>
-     <height>101</height>
+     <height>131</height>
     </rect>
    </property>
    <property name="readOnly">
@@ -62,7 +62,9 @@
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
 p, li { white-space: pre-wrap; }
 &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Project a blue screen on the previously selected output to help you setup your beamer and camera manually. Adjust the position and orientation of your beamer to project the blue frame in your sandbox. Then adjust the position and oritentation of your camera to capture the blue screen projected. Try to set your camera, so the camera's point of view above is mostly filled with the blue screen.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Project a blue screen on the previously selected output to help you setup your beamer and camera manually.&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Firstly, adjust the position and orientation of your beamer to project the blue frame in your sandbox. The red dot indicates the center of the blue screen.&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Then adjust the position and oritentation of your camera to capture the sandbox. Your camera must capture all of the blue screen and must be perpendicular to the sandbox's top.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    </property>
   </widget>
   <widget class="QLabel" name="label">
-- 
GitLab