converter-text.hpp
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 #pragma once
5 
6 
7 #include "../converter.hpp"
8 
9 
10 namespace rs2 {
11 namespace tools {
12 namespace converter {
13 
14 
15 inline std::string frame_to_string( rs2::frame const & f )
16 {
17  std::ostringstream s;
18 
19  if( ! f )
20  {
21  s << "[null]";
22  }
23  else
24  {
25  rs2::frameset fs( f );
26  if( fs )
27  {
28  s << "[";
29  fs.foreach_rs( [&s]( rs2::frame const & sf ) { s << frame_to_string( sf ); } );
30  s << "]";
31  }
32  else
33  {
34  auto p = f.get_profile();
35  s << "[" << rs2_stream_to_string( p.stream_type() );
36  s << "/" << p.unique_id(); //stream_index();
37  s << " #" << f.get_frame_number();
38  s << " @" << std::fixed << (double)f.get_timestamp();
39  s << "]";
40  }
41  }
42  return s.str();
43 }
44 
45 
47 {
49 
50 public:
52  : _streamType( streamType )
53  {
54  }
55 
56  std::string name() const override { return "TEXT converter"; }
57 
58  void convert( rs2::frame & frame ) override
59  {
60  std::cout << frame_to_string( frame ) << std::endl;
61  }
62 };
63 
64 } // namespace converter
65 } // namespace tools
66 } // namespace rs2
void convert(rs2::frame &frame) override
GLdouble s
std::string name() const override
converter_text(rs2_stream streamType=rs2_stream::RS2_STREAM_ANY)
Definition: animated.h:9
double get_timestamp() const
Definition: rs_frame.hpp:476
std::ostream & cout()
double p[GRIDW][GRIDH]
Definition: wave.c:109
void foreach_rs(T action) const
Definition: rs_frame.hpp:1111
std::string frame_to_string(rs2::frame const &f)
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
unsigned long long get_frame_number() const
Definition: rs_frame.hpp:523
const char * rs2_stream_to_string(rs2_stream stream)
Definition: to-string.cpp:635
GLdouble f
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