Marc Klinge il y a 1 an
Parent
commit
27e447c464
4 fichiers modifiés avec 9 ajouts et 17 suppressions
  1. BIN
      3d-scanner-startup-helper
  2. 9 17
      3d-scanner.cpp
  3. BIN
      filtered.ply
  4. BIN
      original.ply

BIN
3d-scanner-startup-helper


+ 9 - 17
3d-scanner.cpp

@@ -1,7 +1,7 @@
 #include <librealsense2/rs.hpp>
 #include <iostream>
 
-// void update_data_and_save(rs2::frame &colorized_depth, rs2::frame data_frame, rs2::points &points, rs2::pointcloud &pc, rs2::colorizer &color_map, rs2::frame &color, const std::string &fileName);
+void update_data_and_save(rs2::frame data_frame, rs2::points &points, rs2::pointcloud &pc, rs2::frame &color, const std::string &fileName);
 
 int main()
 try
@@ -37,7 +37,6 @@ try
     rs2::video_frame color = data.get_color_frame();
     if (!color)
         color = data.get_infrared_frame();
-    original_pc.map_to(color);
     rs2::depth_frame depth_frame = data.get_depth_frame();
 
     rs2::depth_frame filtered = depth_frame;
@@ -59,14 +58,8 @@ try
     filtered = disparity_to_depth.process(filtered);
     // filtered = hole_filter.process(filtered);
 
-    // update_data_and_save(colored_depth, depth_frame, original_points, original_pc, color_map, color, "original");
-    // update_data_and_save(colored_filtered, filtered, filtered_points, filtered_pc, color_map, color, "filtered");
-
-    original_points = original_pc.calculate(depth_frame); // Generate pointcloud from the depth data
-    filtered_points = filtered_pc.calculate(filtered);    // Generate pointcloud from the depth data
-
-    original_points.export_to_ply("original.ply", color);
-    filtered_points.export_to_ply("filtered.ply", color);
+    update_data_and_save(depth_frame, original_points, original_pc, color, "original");
+    update_data_and_save(filtered, filtered_points, filtered_pc, color, "filtered");
 
     return EXIT_SUCCESS;
 }
@@ -81,10 +74,9 @@ catch (const std::exception &e)
     return EXIT_FAILURE;
 }
 
-// void update_data_and_save(rs2::frame &colorized_depth, rs2::frame data_frame, rs2::points &points, rs2::pointcloud &pc, rs2::colorizer &color_map, rs2::frame &color, const std::string &fileName)
-// {
-//     pc.map_to(color);                  // Map the colored depth to the point cloud
-//     points = pc.calculate(data_frame); // Generate pointcloud from the depth data
-//     // colorized_depth = color_map.process(data_frame); // Colorize the depth frame with a color map (vorher: colorized_depth)
-//     points.export_to_ply(fileName, color);
-// }
+void update_data_and_save(rs2::frame data_frame, rs2::points &points, rs2::pointcloud &pc, rs2::frame &color, const std::string &fileName)
+{
+    pc.map_to(color);                               // Map the colored image to the point cloud
+    points = pc.calculate(data_frame);              // Generate pointcloud from the depth data
+    points.export_to_ply(fileName + ".ply", color); // export pointcloud to .ply file
+}

BIN
filtered.ply


BIN
original.ply