converter.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2021 Intel Corporation. All Rights Reserved.
3 
4 #include <fstream>
5 #include "converter.hpp"
6 
7 using namespace rs2::tools::converter;
8 
10 {
11  std::ofstream file;
12 
13  file.open(filename);
14 
15  file << "Stream: " << rs2_stream_to_string(frm.get_profile().stream_type()) << "\n";
16 
17  // Record all the available metadata attributes
18  for (size_t i = 0; i < RS2_FRAME_METADATA_COUNT; i++)
19  {
21  if (frm.supports_frame_metadata(metadata_val))
22  {
23  file << rs2_frame_metadata_to_string(metadata_val) << ": "
24  << frm.get_frame_metadata(metadata_val) << "\n";
25  }
26  }
27 
28  file.close();
29 }
30 
32 {
33  if (_framesMap.find(streamType) == _framesMap.end()) {
34  _framesMap.emplace(streamType, std::unordered_set<frame_number_t>());
35  }
36 
37  auto& set = _framesMap[streamType];
38  bool result = (set.find(frameNumber) != set.end());
39 
40  if (!result) {
41  set.emplace(frameNumber);
42  }
43 
44  return result;
45 }
46 
48 {
49  for_each(_subWorkers.begin(), _subWorkers.end(),
50  [](std::thread& t) {
51  t.join();
52  });
53 
54  _subWorkers.clear();
55 }
56 
58 {
59  _worker.join();
60 }
61 
63 {
64  std::stringstream result;
65  result << name() << '\n';
66 
67  for (auto& i : _framesMap) {
68  result << '\t'
69  << i.second.size() << ' '
70  << (static_cast<rs2_stream>(i.first) != rs2_stream::RS2_STREAM_ANY ? rs2_stream_to_string(static_cast<rs2_stream>(i.first)) : "")
71  << " frame(s) processed"
72  << '\n';
73  }
74 
75  return (result.str());
76 }
77 
rs2::tools::converter::converter_base::_framesMap
std::unordered_map< int, std::unordered_set< frame_number_t > > _framesMap
Definition: converter.hpp:29
rs2::frame
Definition: rs_frame.hpp:345
rs2_stream_to_string
const char * rs2_stream_to_string(rs2_stream stream)
Definition: to-string.cpp:766
string
GLsizei const GLchar *const * string
Definition: glad/glad/glad.h:2861
rs2::stream_profile::stream_type
rs2_stream stream_type() const
Definition: rs_frame.hpp:39
rs2::tools::converter::converter_base::wait_sub_workers
void wait_sub_workers()
Definition: converter.cpp:47
rs2_frame_metadata_to_string
const char * rs2_frame_metadata_to_string(rs2_frame_metadata_value metadata)
Definition: to-string.cpp:793
rs2::frame::supports_frame_metadata
bool supports_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:511
rs2::tools::converter
Definition: converter.hpp:19
converter.hpp
i
int i
Definition: rs-pcl-color.cpp:54
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_STREAM_ANY
@ RS2_STREAM_ANY
Definition: rs_sensor.h:45
RS2_FRAME_METADATA_COUNT
@ RS2_FRAME_METADATA_COUNT
Definition: rs_frame.h:78
test-projection-from-recording.filename
filename
Definition: test-projection-from-recording.py:15
rs2::tools::converter::converter_base::wait
void wait()
Definition: converter.cpp:57
rs2::frame::get_frame_metadata
rs2_metadata_type get_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:499
rs2::tools::converter::metadata_to_txtfile
void metadata_to_txtfile(const rs2::frame &frm, const std::string &filename)
Definition: converter.cpp:9
t
GLdouble t
Definition: glad/glad/glad.h:1829
rs2::tools::converter::converter_base::name
virtual std::string name() const =0
rs2::frame::get_profile
stream_profile get_profile() const
Definition: rs_frame.hpp:559
rs2::tools::converter::converter_base::get_statistics
virtual std::string get_statistics()
Definition: converter.cpp:62
rs2::tools::converter::converter_base::_worker
std::thread _worker
Definition: converter.hpp:27
rs2::tools::converter::frame_number_t
unsigned long long frame_number_t
Definition: converter.hpp:23
rs2_frame_metadata_value
rs2_frame_metadata_value
Per-Frame-Metadata is the set of read-only properties that might be exposed for each individual frame...
Definition: rs_frame.h:29
test-depth.result
result
Definition: test-depth.py:183
rs2_stream
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:43
rs2::tools::converter::converter_base::_subWorkers
std::vector< std::thread > _subWorkers
Definition: converter.hpp:28


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