converter-ply.hpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2018 Intel Corporation. All Rights Reserved.
3 
4 #ifndef __RS_CONVERTER_CONVERTER_PLY_H
5 #define __RS_CONVERTER_CONVERTER_PLY_H
6 
7 
8 #include "../converter.hpp"
9 
10 
11 namespace rs2 {
12  namespace tools {
13  namespace converter {
14 
15  class converter_ply : public converter_base {
16  protected:
17  std::string _filePath;
18 
19  public:
20  converter_ply(const std::string& filePath)
21  : _filePath(filePath)
22  {
23  }
24 
25  std::string name() const override
26  {
27  return "PLY converter";
28  }
29 
30  void convert(rs2::frame& frame) override
31  {
34  [this, &frame, pc]() mutable {
35  auto frameset = frame.as<rs2::frameset>();
36  auto frameDepth = frameset.get_depth_frame();
37  auto frameColor = frameset.get_color_frame();
38 
39  if (frameDepth && frameColor) {
41  return;
42  }
43 
44  pc.map_to(frameColor);
45 
46  auto points = pc.calculate(frameDepth);
47 
48  std::stringstream filename;
49  filename << _filePath
50  << "_" << std::setprecision(14) << std::fixed << frameDepth.get_timestamp()
51  << ".ply";
52 
53  points.export_to_ply(filename.str(), frameColor);
54 
55  std::stringstream metadata_file;
56  metadata_file << _filePath
57  << "_metadata_" << std::setprecision(14) << std::fixed << frameDepth.get_timestamp()
58  << ".txt";
59 
60  metadata_to_txtfile(frameDepth, metadata_file.str());
61  }
62  });
63  }
64  };
65 
66  }
67  }
68 }
69 
70 
71 #endif
void export_to_ply(const std::string &fname, video_frame texture)
Definition: rs_frame.hpp:784
void map_to(frame mapped)
Definition: animated.h:9
double get_timestamp() const
Definition: rs_frame.hpp:476
converter_ply(const std::string &filePath)
video_frame get_color_frame() const
Definition: rs_frame.hpp:1019
void convert(rs2::frame &frame) override
bool frames_map_get_and_set(rs2_stream streamType, frame_number_t frameNumber)
Definition: converter.cpp:31
T as() const
Definition: rs_frame.hpp:582
points calculate(frame depth) const
unsigned long long get_frame_number() const
Definition: rs_frame.hpp:523
void metadata_to_txtfile(const rs2::frame &frm, const std::string &filename)
Definition: converter.cpp:9
depth_frame get_depth_frame() const
Definition: rs_frame.hpp:1010
std::string name() const override


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:43:16