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:
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;
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
rs2::frameset::get_depth_frame
depth_frame get_depth_frame() const
Definition: rs_frame.hpp:1010
rs2::frame
Definition: rs_frame.hpp:345
rs2::frameset
Definition: rs_frame.hpp:947
rs2::tools::converter::converter_ply::_filePath
std::string _filePath
Definition: converter-ply.hpp:17
rs2::frame::get_frame_number
unsigned long long get_frame_number() const
Definition: rs_frame.hpp:523
string
GLsizei const GLchar *const * string
Definition: glad/glad/glad.h:2861
rs2::tools::converter::converter_ply::convert
void convert(rs2::frame &frame) override
Definition: converter-ply.hpp:30
rs2::tools::converter::converter_ply
Definition: converter-ply.hpp:15
rs2::frame::get_timestamp
double get_timestamp() const
Definition: rs_frame.hpp:476
rs2::points
Definition: rs_frame.hpp:739
rs2::tools::converter::converter_ply::converter_ply
converter_ply(const std::string &filePath)
Definition: converter-ply.hpp:20
rs2
Definition: animated.h:9
rs2::tools::converter::converter_base::frames_map_get_and_set
bool frames_map_get_and_set(rs2_stream streamType, frame_number_t frameNumber)
Definition: converter.cpp:31
rs2::tools::converter::converter_base
Definition: converter.hpp:25
RS2_STREAM_ANY
@ RS2_STREAM_ANY
Definition: rs_sensor.h:45
tools
Definition: lrs-device-controller.h:26
test-projection-from-recording.filename
filename
Definition: test-projection-from-recording.py:15
rs2::frameset::get_color_frame
video_frame get_color_frame() const
Definition: rs_frame.hpp:1019
rs2::tools::converter::metadata_to_txtfile
void metadata_to_txtfile(const rs2::frame &frm, const std::string &filename)
Definition: converter.cpp:9
rs2::frame::as
T as() const
Definition: rs_frame.hpp:582
rs2::tools::converter::converter_base::start_worker
void start_worker(const F &f)
Definition: converter.hpp:35
rs2::tools::converter::converter_ply::name
std::string name() const override
Definition: converter-ply.hpp:25
rs2::points::export_to_ply
void export_to_ply(const std::string &fname, video_frame texture)
Definition: rs_frame.hpp:784
rs2::pointcloud
Definition: rs_processing.hpp:430
test-post-processing-from-bag.pc
pc
Definition: test-post-processing-from-bag.py:120


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Fri Aug 2 2024 08:30:01