leon 1 kuukausi sitten
vanhempi
commit
0d34f2b729
3 muutettua tiedostoa jossa 29 lisäystä ja 2 poistoa
  1. 0 1
      src/nodes/draw/drawNode.cpp
  2. 28 0
      src/nodes/httpPush/httpPush.cpp
  3. 1 1
      src/nodes/infer/inferNode.cpp

+ 0 - 1
src/nodes/draw/drawNode.cpp

@@ -52,7 +52,6 @@ void DrawNode::work()
                 // printf("Node %s push data to %s\n", name_.c_str(), output_buffer.first.c_str());
                 output_buffer.second->push(metaData);
             }
-            std::cout << "depth map size : " << metaData->depth.size() << std::endl;
         }
         if (!has_data) {
             // printf("draw wait data\n");

+ 28 - 0
src/nodes/httpPush/httpPush.cpp

@@ -5,6 +5,27 @@
 namespace Node
 {
 
+static cv::Mat get_color_depth(cv::Mat inverse_depth)
+{
+    double min_val, max_val;
+    cv::minMaxLoc(inverse_depth, &min_val, &max_val);
+
+    float max_invdepth_vizu = std::min(static_cast<float>(max_val), 1.0f / 0.1f);
+    float min_invdepth_vizu = std::max(static_cast<float>(1.0 / 250.0), static_cast<float>(min_val));
+
+    cv::Mat inverse_depth_normalized = (inverse_depth - min_invdepth_vizu) / (max_invdepth_vizu - min_invdepth_vizu);
+    
+    cv::Mat inverse_depth_normalized_8u;
+    inverse_depth_normalized.convertTo(inverse_depth_normalized_8u, CV_8UC1, 255);
+
+    cv::Mat color_depth;
+    cv::applyColorMap(inverse_depth_normalized_8u, color_depth, cv::COLORMAP_JET);
+
+    cv::Mat color_depth_bgr;
+    cv::cvtColor(color_depth, color_depth_bgr, cv::COLOR_BGR2RGB);
+    return color_depth_bgr;
+}
+
 void HttpPushNode::work()
 {
     printf("HttpPush %s\n", name_.c_str());
@@ -24,6 +45,13 @@ void HttpPushNode::work()
             cv::Mat image = metaData->draw_image;
             std::string image_name = "result/" + metaData->from + "_" + getTimeString() + ".jpg";
             cv::imwrite(image_name, image);
+
+            if (!metaData->depth.empty())
+            {
+                get_color_depth(metaData->depth);
+                std::string depth_name = "result/" + metaData->from + "_depth_" + getTimeString() + ".jpg";
+                cv::imwrite(depth_name, get_color_depth(metaData->depth));
+            }
         }
         if (!has_data) {
             std::unique_lock<std::mutex> lock(mutex_);

+ 1 - 1
src/nodes/infer/inferNode.cpp

@@ -20,7 +20,7 @@ void InferNode::work()
                 continue;
             }
             has_data = true;
-            printf("Node %s get data from %s\n", name_.c_str(), input_buffer.first.c_str());
+            // printf("Node %s get data from %s\n", name_.c_str(), input_buffer.first.c_str());
             cv::Mat image = metaData->image;
             int width = image.cols;
             int height = image.rows;