From 5b80f3fd9214ce716e2e6cd83e7d29afe9bcb1d1 Mon Sep 17 00:00:00 2001
From: "simon.fanetti" <simon.fanetti@etu.hesge.ch>
Date: Thu, 11 Jun 2020 21:38:29 +0200
Subject: [PATCH] change default param in CameraFocus

---
 app/SandboxSetup/camerafocus.ui | 6 +++---
 src/components/beamer.cpp       | 4 +++-
 src/components/camera.cpp       | 2 ++
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/app/SandboxSetup/camerafocus.ui b/app/SandboxSetup/camerafocus.ui
index 8bbd4a1..f956356 100644
--- a/app/SandboxSetup/camerafocus.ui
+++ b/app/SandboxSetup/camerafocus.ui
@@ -125,7 +125,7 @@
     <item row="1" column="2">
      <widget class="QSpinBox" name="sbxBrightness">
       <property name="minimum">
-       <number>-255</number>
+       <number>-65025</number>
       </property>
       <property name="maximum">
        <number>255</number>
@@ -253,7 +253,7 @@
        <number>0</number>
       </property>
       <property name="maximum">
-       <number>500</number>
+       <number>300</number>
       </property>
       <property name="value">
        <number>100</number>
@@ -344,7 +344,7 @@
     <item row="1" column="1">
      <widget class="QSlider" name="sldBrightness">
       <property name="minimum">
-       <number>-255</number>
+       <number>-765</number>
       </property>
       <property name="maximum">
        <number>255</number>
diff --git a/src/components/beamer.cpp b/src/components/beamer.cpp
index e65277d..03716aa 100644
--- a/src/components/beamer.cpp
+++ b/src/components/beamer.cpp
@@ -84,7 +84,9 @@ int Beamer::findBeamerFrom(Camera *camera){
 cv::Point3f Beamer::deprojectPixel(cv::Point3i circle, cv::Mat *depth, Camera *camera){
     float coord[2] = {(float)circle.x, (float)circle.y};
     float z = static_cast<float>(depth->at<uint16_t>(circle.y, circle.x));
-    return camera->deprojectPixelToPoint(coord, z / 1000.0);
+    // rs2.get_depth_frame().get_units()
+    float depth_unit = 1 / 1000.0;
+    return camera->deprojectPixelToPoint(coord, z * depth_unit);
 }
 
 void Beamer::findLinearLineFrom(std::vector<cv::Point3f> *capturedPoints, std::vector<cv::Point3d> *bases, std::vector<cv::Point3d> *directions){
diff --git a/src/components/camera.cpp b/src/components/camera.cpp
index 44442df..8ba7e98 100644
--- a/src/components/camera.cpp
+++ b/src/components/camera.cpp
@@ -61,7 +61,9 @@ void Camera::capture(){
     rs2::video_frame color_frame = frameset.get_color_frame();
     rs2::depth_frame depth_frame = frameset.get_depth_frame();
     filterDepthFrame(depth_frame);
+    // intrinsics.model : Brown Conrady
     matDepth = cv::Mat(cv::Size(depth_frame.get_width(), depth_frame.get_height()), CV_16UC1, (void *)depth_frame.get_data(), cv::Mat::AUTO_STEP);
+    // depth_frame.get_distance(x,y) == ((float)matDepth.at<uint16_t>(y, x) * depth_frame.get_units())
     cv::Mat(cv::Size(color_frame.get_width(), color_frame.get_height()), CV_8UC3, (void *)color_frame.get_data(), cv::Mat::AUTO_STEP).copyTo(matRGB);
 }
 
-- 
GitLab