From d0526fb92b522af1398f88e8c766d15a0cb170d7 Mon Sep 17 00:00:00 2001
From: "simon.fanetti" <simon.fanetti@etu.hesge.ch>
Date: Fri, 12 Jun 2020 21:00:59 +0200
Subject: [PATCH] adapt inputs + add unrestricted button in CameraFocus

---
 app/Makefile                           |  6 +-
 app/SandboxSetup/SandboxSetup.pro      |  2 +-
 app/SandboxSetup/beamerlocationgui.cpp | 10 +--
 app/SandboxSetup/camerafocus.cpp       | 86 ++++++++++++++++++-------
 app/SandboxSetup/camerafocus.h         |  3 +
 app/SandboxSetup/camerafocus.ui        | 87 ++++++++++++++------------
 app/SandboxSetup/croppingmask.ui       |  4 +-
 inc/beamer.h                           | 28 ++++++---
 src/components/beamer.cpp              |  2 -
 src/components/camera.cpp              | 10 ++-
 src/tools/sandboxConfig.cpp            |  8 ---
 11 files changed, 151 insertions(+), 95 deletions(-)

diff --git a/app/Makefile b/app/Makefile
index 9ec5ee3..cd2d75d 100644
--- a/app/Makefile
+++ b/app/Makefile
@@ -1,14 +1,16 @@
 LIBPATH=../../build
 SUBDIR=SandboxSetup
 
+.PHONY: genMakefile genExe
+
 all: 
 	-$(MAKE) genMakefile
 	-$(MAKE) genExe
 
-genMakefile:
+genMakefile: $(SUBDIR)/$(SUBDIR).pro
 	$(shell cd $(SUBDIR) && qmake *.pro)
 
-genExe:
+genExe: $(SUBDIR)/Makefile
 	$(shell cd $(SUBDIR) && export LD_LIBRARY_PATH=$(pwd)/$(LIBPATH) && make)
 
 clean:
diff --git a/app/SandboxSetup/SandboxSetup.pro b/app/SandboxSetup/SandboxSetup.pro
index 7e0806f..a699d0a 100644
--- a/app/SandboxSetup/SandboxSetup.pro
+++ b/app/SandboxSetup/SandboxSetup.pro
@@ -69,4 +69,4 @@ INCLUDEPATH += ../../inc
 LIBS += -L"../../build" -lsandbox -lrealsense2 -lyaml-cpp
 LIBS += $(shell pkg-config --libs --cflags opencv)
 
-#CONFIG += -fsanitize=address -fsanitize=leak -fsanitize=undefined
+#QMAKE_CXXFLAGS += -fsanitize=address -fsanitize=leak -fsanitize=undefined
diff --git a/app/SandboxSetup/beamerlocationgui.cpp b/app/SandboxSetup/beamerlocationgui.cpp
index 378e6cc..51592d6 100644
--- a/app/SandboxSetup/beamerlocationgui.cpp
+++ b/app/SandboxSetup/beamerlocationgui.cpp
@@ -96,15 +96,15 @@ void BeamerLocationGui::routineFrame(){
         rgb = camera->getColorFrame();
 
         // Look for the circle target
-        double minDist = rgb.cols / (double)profil->getMinDistance();
-        double minRadius = (profil->getMinRadius()>0) ? rgb.cols/(double)profil->getMinRadius() : 0;
-        double maxRadius = (profil->getMaxRadius()>0) ? rgb.cols/(double)profil->getMaxRadius() : 0;
+        double minDist = rgb.cols*(double)profil->getMinDistance()/100;
+        double minRadius = (profil->getMinRadius()>0) ? rgb.cols*(double)profil->getMinRadius()/100 : 0;
+        double maxRadius = (profil->getMaxRadius()>0) ? rgb.cols*(double)profil->getMaxRadius()/100 : 0;
         circle = beamer->findCircles(  rgb,
                                        profil->getContrast(),
                                        profil->getBrightness(),
                                        minDist,
-                                       profil->getCannyEdgeThreshold(),
-                                       profil->getHoughAccThreshold(),
+                                       (int)profil->getCannyEdgeThreshold(),
+                                       (int)profil->getHoughAccThreshold(),
                                        minRadius,
                                        maxRadius );
 
diff --git a/app/SandboxSetup/camerafocus.cpp b/app/SandboxSetup/camerafocus.cpp
index 7244162..c5e45a3 100644
--- a/app/SandboxSetup/camerafocus.cpp
+++ b/app/SandboxSetup/camerafocus.cpp
@@ -20,11 +20,9 @@ CameraFocus::CameraFocus(SandboxSetup *sandbox, MonitorGui *_mg, QWidget *parent
     setup = sandbox;
     mg = _mg;
     myThread = new RefreshFrame(this);
-    //connect(myThread, &RefreshFrame::finished, myThread, &QObject::deleteLater);
     blackScreen = new QtFullScreen(mg->getResolution(), true, this);
-
     setup->loadFrameProcessProfil();
-    initCameraParams();
+
     frameTimer = new QTimer(this);
     connect(frameTimer, &QTimer::timeout, this, &CameraFocus::startCapture);
 }
@@ -41,13 +39,11 @@ CameraFocus::~CameraFocus()
 
 void CameraFocus::showEvent(QShowEvent *event){
 
-    setup->getCamera()->capture();
-    cv::Mat rgb = setup->getCamera()->getColorFrame();
-    // we assume the matrixe for the accumulators has a ratio of 1 with the captured frame
-    ui->sbxAccThreshold->setMaximum( rgb.cols*rgb.rows );
-
     QWidget::showEvent(event);
-    cv::Mat black = cv::Mat(1, 1, CV_8UC3, cv::Scalar(0, 0, 0));
+    initCameraParams();
+    cv::Mat black = cv::Mat(setup->getBeamer()->getHeight(), setup->getBeamer()->getWidth(), CV_8UC3, cv::Scalar(0, 0, 0));
+    cv::line(black, cv::Point(black.cols/2, 0), cv::Point(black.cols/2, black.rows-1), cv::Scalar(255, 0, 0), 4);
+    cv::line(black, cv::Point(0, black.rows/2), cv::Point(black.cols-1, black.rows/2), cv::Scalar(255, 0, 0), 4);
     blackScreen->editGeometry(mg->getResolution());
     blackScreen->imShow(black);
     frameTimer->start(100);
@@ -87,15 +83,15 @@ void CameraFocus::refreshFrame(){
 
     if(profil->getCannyEdgeThreshold() > 0 && profil->getHoughAccThreshold() > 0){
 
-        double minDist = rgb.cols / (double)profil->getMinDistance();
-        double minRadius = (profil->getMinRadius()>0) ? rgb.cols/(double)profil->getMinRadius() : 0;
-        double maxRadius = (profil->getMaxRadius()>0) ? rgb.cols/(double)profil->getMaxRadius() : 0;
+        double minDist = rgb.cols*(double)profil->getMinDistance()/100;
+        double minRadius = (profil->getMinRadius()>0) ? rgb.cols*(double)profil->getMinRadius()/100 : 0;
+        double maxRadius = (profil->getMaxRadius()>0) ? rgb.cols*(double)profil->getMaxRadius()/100 : 0;
         crc = setup->getBeamer()->findCircles( rgb,
                                                profil->getContrast(),
                                                profil->getBrightness(),
                                                minDist,
-                                               profil->getCannyEdgeThreshold(),
-                                               profil->getHoughAccThreshold(),
+                                               (int)profil->getCannyEdgeThreshold(),
+                                               (int)profil->getHoughAccThreshold(),
                                                minRadius,
                                                maxRadius );
     }
@@ -133,24 +129,33 @@ void CameraFocus::initCameraParams(){
 
 void CameraFocus::loadProfil(FrameProcessProfil *profilLoaded, FrameProcessProfil *profilSaved){
 
+    // save profil
     profilSaved->setContrast(profilLoaded->getContrast());
     profilSaved->setBrightness(profilLoaded->getBrightness());
     profilSaved->setMinDistance(profilLoaded->getMinDistance());
     profilSaved->setCannyEdgeThreshold(profilLoaded->getCannyEdgeThreshold());
     profilSaved->setHoughAccThreshold(profilLoaded->getHoughAccThreshold());
 
+    bool isUnrestricted = profilLoaded->getContrast() > 5.00 ||
+                          profilLoaded->getBrightness() < -1275 ||
+                          profilLoaded->getHoughAccThreshold() > 300;
+
+    ui->ckbxAdvanced->setChecked(isUnrestricted);
+    switchMode(!isUnrestricted);
 
-    ui->sbxContrast->setValue(profilLoaded->getContrast());
-    ui->sbxBrightness->setValue(profilLoaded->getBrightness());
-    ui->sbxMinDistance->setValue(profilLoaded->getMinDistance());
-    ui->sbxCannyThreshold->setValue(profilLoaded->getCannyEdgeThreshold());
-    ui->sbxAccThreshold->setValue(profilLoaded->getHoughAccThreshold());
+    // set values
+    ui->sbxContrast->setValue((double)profilLoaded->getContrast());
+    ui->sbxBrightness->setValue((int)profilLoaded->getBrightness());
+    ui->sbxMinDistance->setValue((int)profilLoaded->getMinDistance());
+    ui->sbxCannyThreshold->setValue((int)profilLoaded->getCannyEdgeThreshold());
+    ui->sbxAccThreshold->setValue((int)profilLoaded->getHoughAccThreshold());
 
+    // check for the known target's size
     if(profilLoaded->getMinRadius() > 0 && profilLoaded->getMaxRadius() > 0){
-        profilSaved->setMinRadius(profilLoaded->getMinRadius());
-        profilSaved->setMaxRadius(profilLoaded->getMaxRadius());
-        ui->sbxMinRadius->setValue(profilLoaded->getMinRadius());
-        ui->sbxMaxRadius->setValue(profilLoaded->getMaxRadius());
+        profilSaved->setMinRadius((int)profilLoaded->getMinRadius());
+        profilSaved->setMaxRadius((int)profilLoaded->getMaxRadius());
+        ui->sbxMinRadius->setValue((int)profilLoaded->getMinRadius());
+        ui->sbxMaxRadius->setValue((int)profilLoaded->getMaxRadius());
         ui->ckbxTargetSize->setChecked(true);
         ui->ckbxTargetSize->clicked(true);
     }else{
@@ -265,3 +270,38 @@ void CameraFocus::on_ckbxTargetSize_clicked(bool checked)
     setup->getBeamer()->getProfil()->setMinRadius(min);
     setup->getBeamer()->getProfil()->setMaxRadius(max);
 }
+
+
+void CameraFocus::switchMode(bool isRestricted){
+
+    if(isRestricted){
+        ui->sldContrast->setMaximum(500);
+        ui->sbxContrast->setMaximum(5.00);
+
+        ui->sldBrightness->setMinimum(-1275);
+        ui->sbxBrightness->setMinimum(-1275);
+
+        ui->sldAccThreshold->setMaximum(300);
+        ui->sbxAccThreshold->setMaximum(300);
+
+    }else{
+        // we assume the matrixe for the accumulators has a ratio of 1 with the captured frame
+        setup->getCamera()->capture();
+        cv::Mat rgb = setup->getCamera()->getColorFrame();
+        int maxHough = rgb.cols*rgb.rows;
+
+        ui->sldContrast->setMaximum(25500);
+        ui->sbxContrast->setMaximum(255.00);
+
+        ui->sldBrightness->setMinimum(-65025);
+        ui->sbxBrightness->setMinimum(-65025);
+
+        ui->sldAccThreshold->setMaximum(maxHough);
+        ui->sbxAccThreshold->setMaximum(maxHough);
+    }
+}
+
+void CameraFocus::on_ckbxAdvanced_clicked(bool checked)
+{
+    switchMode(!checked);
+}
diff --git a/app/SandboxSetup/camerafocus.h b/app/SandboxSetup/camerafocus.h
index 2df9e48..d756c7f 100644
--- a/app/SandboxSetup/camerafocus.h
+++ b/app/SandboxSetup/camerafocus.h
@@ -60,6 +60,8 @@ private slots:
 
     void on_ckbxTargetSize_clicked(bool checked);
 
+    void on_ckbxAdvanced_clicked(bool checked);
+
 protected:
     void showEvent(QShowEvent *event);
     void closeEvent(QCloseEvent *event);
@@ -87,6 +89,7 @@ private:
     void startCapture();
     void loadProfil(FrameProcessProfil *profilLoaded, FrameProcessProfil *profilSaved);
     void initCameraParams();
+    void switchMode(bool isRestricted);
 };
 
 
diff --git a/app/SandboxSetup/camerafocus.ui b/app/SandboxSetup/camerafocus.ui
index f956356..319f8f5 100644
--- a/app/SandboxSetup/camerafocus.ui
+++ b/app/SandboxSetup/camerafocus.ui
@@ -39,7 +39,7 @@
    <property name="geometry">
     <rect>
      <x>680</x>
-     <y>280</y>
+     <y>270</y>
      <width>89</width>
      <height>25</height>
     </rect>
@@ -100,29 +100,29 @@
    <property name="geometry">
     <rect>
      <x>60</x>
-     <y>320</y>
+     <y>310</y>
      <width>671</width>
-     <height>301</height>
+     <height>311</height>
     </rect>
    </property>
    <layout class="QGridLayout" name="glytParams">
-    <item row="2" column="1">
+    <item row="3" column="1">
      <widget class="QSlider" name="sldMinDistance">
       <property name="minimum">
        <number>1</number>
       </property>
       <property name="maximum">
-       <number>20</number>
+       <number>100</number>
       </property>
       <property name="value">
-       <number>8</number>
+       <number>15</number>
       </property>
       <property name="orientation">
        <enum>Qt::Horizontal</enum>
       </property>
      </widget>
     </item>
-    <item row="1" column="2">
+    <item row="2" column="2">
      <widget class="QSpinBox" name="sbxBrightness">
       <property name="minimum">
        <number>-65025</number>
@@ -135,14 +135,14 @@
       </property>
      </widget>
     </item>
-    <item row="4" column="0">
+    <item row="5" column="0">
      <widget class="QLabel" name="label_5">
       <property name="text">
        <string>Hough accumulator threshold</string>
       </property>
      </widget>
     </item>
-    <item row="6" column="2">
+    <item row="7" column="2">
      <widget class="QSpinBox" name="sbxMinRadius">
       <property name="enabled">
        <bool>false</bool>
@@ -151,21 +151,21 @@
        <number>1</number>
       </property>
       <property name="maximum">
-       <number>20</number>
+       <number>100</number>
       </property>
       <property name="value">
        <number>10</number>
       </property>
      </widget>
     </item>
-    <item row="1" column="0">
+    <item row="2" column="0">
      <widget class="QLabel" name="label_2">
       <property name="text">
        <string>Brightness</string>
       </property>
      </widget>
     </item>
-    <item row="7" column="2">
+    <item row="8" column="2">
      <widget class="QSpinBox" name="sbxMaxRadius">
       <property name="enabled">
        <bool>false</bool>
@@ -174,38 +174,38 @@
        <number>1</number>
       </property>
       <property name="maximum">
-       <number>20</number>
+       <number>100</number>
       </property>
       <property name="value">
-       <number>2</number>
+       <number>50</number>
       </property>
      </widget>
     </item>
-    <item row="3" column="0">
+    <item row="4" column="0">
      <widget class="QLabel" name="label_4">
       <property name="text">
        <string>Upper Canny threshold</string>
       </property>
      </widget>
     </item>
-    <item row="6" column="0">
+    <item row="7" column="0">
      <widget class="QLabel" name="lblMinRadius">
       <property name="enabled">
        <bool>false</bool>
       </property>
       <property name="text">
-       <string>Minimum circle radius (divisor from the camera's width)</string>
+       <string>Minimum circle radius (% of the camera's width)</string>
       </property>
      </widget>
     </item>
-    <item row="0" column="0">
+    <item row="1" column="0">
      <widget class="QLabel" name="label">
       <property name="text">
        <string>Contrast</string>
       </property>
      </widget>
     </item>
-    <item row="6" column="1">
+    <item row="7" column="1">
      <widget class="QSlider" name="sldMinRadius">
       <property name="enabled">
        <bool>false</bool>
@@ -214,7 +214,7 @@
        <number>1</number>
       </property>
       <property name="maximum">
-       <number>20</number>
+       <number>100</number>
       </property>
       <property name="value">
        <number>10</number>
@@ -224,10 +224,10 @@
       </property>
      </widget>
     </item>
-    <item row="2" column="0">
+    <item row="3" column="0">
      <widget class="QLabel" name="label_3">
       <property name="text">
-       <string>Minimum distance between circles's center (divisor from the camera's width)</string>
+       <string>Minimum distance between circles's center (% of the camera's width)</string>
       </property>
       <property name="textFormat">
        <enum>Qt::AutoText</enum>
@@ -237,7 +237,7 @@
       </property>
      </widget>
     </item>
-    <item row="3" column="2">
+    <item row="4" column="2">
      <widget class="QSpinBox" name="sbxCannyThreshold">
       <property name="maximum">
        <number>255</number>
@@ -247,13 +247,13 @@
       </property>
      </widget>
     </item>
-    <item row="0" column="1">
+    <item row="1" column="1">
      <widget class="QSlider" name="sldContrast">
       <property name="minimum">
        <number>0</number>
       </property>
       <property name="maximum">
-       <number>300</number>
+       <number>500</number>
       </property>
       <property name="value">
        <number>100</number>
@@ -263,30 +263,30 @@
       </property>
      </widget>
     </item>
-    <item row="2" column="2">
+    <item row="3" column="2">
      <widget class="QSpinBox" name="sbxMinDistance">
       <property name="minimum">
        <number>1</number>
       </property>
       <property name="maximum">
-       <number>20</number>
+       <number>100</number>
       </property>
       <property name="value">
-       <number>8</number>
+       <number>15</number>
       </property>
      </widget>
     </item>
-    <item row="7" column="0">
+    <item row="8" column="0">
      <widget class="QLabel" name="lblMaxRadius">
       <property name="enabled">
        <bool>false</bool>
       </property>
       <property name="text">
-       <string>Maximum circle radius (divisor from the camera's width)</string>
+       <string>Maximum circle radius (% of the camera's width)</string>
       </property>
      </widget>
     </item>
-    <item row="0" column="2">
+    <item row="1" column="2">
      <widget class="QDoubleSpinBox" name="sbxContrast">
       <property name="minimum">
        <double>0.010000000000000</double>
@@ -302,7 +302,7 @@
       </property>
      </widget>
     </item>
-    <item row="3" column="1">
+    <item row="4" column="1">
      <widget class="QSlider" name="sldCannyThreshold">
       <property name="maximum">
        <number>255</number>
@@ -315,7 +315,7 @@
       </property>
      </widget>
     </item>
-    <item row="4" column="2">
+    <item row="5" column="2">
      <widget class="QSpinBox" name="sbxAccThreshold">
       <property name="maximum">
        <number>300</number>
@@ -325,7 +325,7 @@
       </property>
      </widget>
     </item>
-    <item row="4" column="1">
+    <item row="5" column="1">
      <widget class="QSlider" name="sldAccThreshold">
       <property name="maximum">
        <number>300</number>
@@ -341,10 +341,10 @@
       </property>
      </widget>
     </item>
-    <item row="1" column="1">
+    <item row="2" column="1">
      <widget class="QSlider" name="sldBrightness">
       <property name="minimum">
-       <number>-765</number>
+       <number>-1275</number>
       </property>
       <property name="maximum">
        <number>255</number>
@@ -354,7 +354,7 @@
       </property>
      </widget>
     </item>
-    <item row="7" column="1">
+    <item row="8" column="1">
      <widget class="QSlider" name="sldMaxRadius">
       <property name="enabled">
        <bool>false</bool>
@@ -363,23 +363,30 @@
        <number>1</number>
       </property>
       <property name="maximum">
-       <number>20</number>
+       <number>100</number>
       </property>
       <property name="value">
-       <number>2</number>
+       <number>50</number>
       </property>
       <property name="orientation">
        <enum>Qt::Horizontal</enum>
       </property>
      </widget>
     </item>
-    <item row="5" column="0">
+    <item row="6" column="0">
      <widget class="QCheckBox" name="ckbxTargetSize">
       <property name="text">
        <string>Target's size known</string>
       </property>
      </widget>
     </item>
+    <item row="0" column="0">
+     <widget class="QCheckBox" name="ckbxAdvanced">
+      <property name="text">
+       <string>Unrestricted</string>
+      </property>
+     </widget>
+    </item>
    </layout>
   </widget>
  </widget>
diff --git a/app/SandboxSetup/croppingmask.ui b/app/SandboxSetup/croppingmask.ui
index 030968b..2f4ec8e 100644
--- a/app/SandboxSetup/croppingmask.ui
+++ b/app/SandboxSetup/croppingmask.ui
@@ -63,7 +63,7 @@
      <x>40</x>
      <y>370</y>
      <width>561</width>
-     <height>91</height>
+     <height>101</height>
     </rect>
    </property>
    <property name="readOnly">
@@ -74,7 +74,7 @@
 &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;At this point, the beamer and the blue screen should be set correctly. So now we want to determine the edges of the blue screen. To do that, be sure to have a flat surface to have a clean blue rectangle projected. (ie. you can use a cardboard as support). Then drag the corners to match the bluescreen's edges.&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;At this point, the beamer and the blue screen should be set correctly. So now we want to determine the edges of the blue screen. To do that, be sure to have a flat surface to have a clean blue rectangle projected. (ie. you can use a cardboard as support). Then drag the corners of the green rectangle to match the bluescreen's corners.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    </property>
   </widget>
  </widget>
diff --git a/inc/beamer.h b/inc/beamer.h
index 203743a..08d9f6f 100644
--- a/inc/beamer.h
+++ b/inc/beamer.h
@@ -6,18 +6,17 @@
 
 class FrameProcessProfil{
     private:
-        double contrast; // [0, 255]
-        int brightness; // [-255, 255]
-        // radius of the circle based on the width of the frame, where :
-        // radius = frame.width / ratioRadius
-        uint minDistance; // [1, n]
+        // Profil to process on gray scaled images
+        double contrast; // ]0, 255]
+        int brightness; // [-2^16, 255]
+        uint minDistance; // [1, 100] % of the frame's width
         uint cannyEdgeThreshold; // [0, 255] the strongest the contrast in the image is, the higher this param should be
-        uint houghAccThreshold; // [0, n] should be set way lower than upperMin if cicles have weak contrasts at their edges
-        uint minRadius;
-        uint maxRadius;
+        uint houghAccThreshold; // [0, n] where n = width*height of the frame
+        uint minRadius; // [1, 100] % of the frame's width
+        uint maxRadius; // [1, 100] % of the frame's width
 
     public:
-        FrameProcessProfil(double c=1.0, int b=0, int d=8, uint cannyThreshold=100, uint accThreshold=50, uint minR=10, uint maxR=2){
+        FrameProcessProfil(double c=1.0, int b=0, int d=15, uint cannyThreshold=100, uint accThreshold=50, uint minR=10, uint maxR=50){
             contrast = c;
             brightness = b;
             minDistance = d;
@@ -41,11 +40,20 @@ class FrameProcessProfil{
         uint getMaxRadius(){ return maxRadius; };
         void setMaxRadius(uint max){ maxRadius = max; };
 
+        void print(){
+            std::cout << contrast << std::endl;
+            std::cout << brightness << std::endl;
+            std::cout << minDistance << std::endl;
+            std::cout << cannyEdgeThreshold << std::endl;
+            std::cout << houghAccThreshold << std::endl;
+            std::cout << minRadius << std::endl;
+            std::cout << maxRadius << std::endl;
+        }
+
 };
 
 class Beamer{
     private:
-        const char *BEAMER_POSITION_FILE = "./beamer.dat";
         cv::Point3f beamerPosition;
         cv::Size resolution = cv::Size(256,144);
         FrameProcessProfil profil = FrameProcessProfil();
diff --git a/src/components/beamer.cpp b/src/components/beamer.cpp
index 03716aa..055151d 100644
--- a/src/components/beamer.cpp
+++ b/src/components/beamer.cpp
@@ -246,8 +246,6 @@ std::vector<cv::Point3i> Beamer::findCircles(cv::Mat &rgb, double contrast, int
     // min_radius   : Min radius of the circles drew on the accumulator
     // max_radius   : Max radius of the circles drew on the accumulator
     cv::HoughCircles(src_gray, circles, CV_HOUGH_GRADIENT, 1, centersMinDist, (double)cannyEdgeThreshold, (double)houghAccThreshold, minRadius, maxRadius);
-    
-    //doit tester si le cercle est bon (rayon);
 
     std::vector<cv::Point3i> result;
     if (!circles.empty())
diff --git a/src/components/camera.cpp b/src/components/camera.cpp
index 8ba7e98..e38276b 100644
--- a/src/components/camera.cpp
+++ b/src/components/camera.cpp
@@ -14,14 +14,20 @@ Camera::Camera() {
 
 void Camera::start(){
     
+    // check for a device availible
+    if(!cfg.can_resolve(pipe)){
+        std::cout << "Error: No device found" << std::endl;
+        exit(0);
+    }
+
     std::remove("./camera.logs");
     rs2::log_to_file(RS2_LOG_SEVERITY_DEBUG, "./camera.logs");
-    
     //rs2::log_to_console(RS2_LOG_SEVERITY_DEBUG);//RS2_LOG_SEVERITY_ERROR);
+
     spatFilter.set_option(RS2_OPTION_HOLES_FILL, 5);
-    //cfg.enable_device_from_file("../input/flux/flux5.bag");
     profile = pipe.start(cfg);
     auto sensor = profile.get_device().first<rs2::depth_sensor>();
+
     // TODO: At the moment the SDK does not offer a closed enum for D400 visual presets
     // We do this to reduce the number of black pixels
     // The hardware can perform hole-filling much better and much more power efficient then our software
diff --git a/src/tools/sandboxConfig.cpp b/src/tools/sandboxConfig.cpp
index 1d85fe5..bfa736c 100644
--- a/src/tools/sandboxConfig.cpp
+++ b/src/tools/sandboxConfig.cpp
@@ -301,14 +301,6 @@ int SandboxConfig::loadFrameProcessProfil(char *path, FrameProcessProfil *profil
     profil->setMinRadius(config[PROCESSPROFIL]["minRadius"].as<uint>());
     profil->setMaxRadius(config[PROCESSPROFIL]["maxRadius"].as<uint>());
 
-/*
-    std::cout << config[PROCESSPROFIL]["contrast"].as<double>();
-    std::cout << config[PROCESSPROFIL]["brightness"].as<int>();
-    std::cout << config[PROCESSPROFIL]["radiusRatio"].as<uint>();
-    std::cout << config[PROCESSPROFIL]["contrast"].as<double>();
-    std::cout << config[PROCESSPROFIL]["contrast"].as<double>();
-*/
-
     return 0;
 }
 
-- 
GitLab