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 
const char * rs2_frame_metadata_to_string(rs2_frame_metadata_value metadata)
Definition: to-string.cpp:649
GLdouble t
bool frames_map_get_and_set(rs2_stream streamType, frame_number_t frameNumber)
Definition: converter.cpp:31
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
void metadata_to_txtfile(const rs2::frame &frm, const std::string &filename)
Definition: converter.cpp:9
std::vector< std::thread > _subWorkers
Definition: converter.hpp:28
const char * rs2_stream_to_string(rs2_stream stream)
Definition: to-string.cpp:635
virtual std::string name() const =0
int i
rs2_metadata_type get_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:499
bool supports_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:511
rs2_stream stream_type() const
Definition: rs_frame.hpp:39
unsigned long long frame_number_t
Definition: converter.hpp:23
virtual std::string get_statistics()
Definition: converter.cpp:62
std::unordered_map< int, std::unordered_set< frame_number_t > > _framesMap
Definition: converter.hpp:29
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
stream_profile get_profile() const
Definition: rs_frame.hpp:559


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